Wednesday, March 21, 2012
Generating report from Code
Application without user intervention.
So basically, a user clicks a button, and a report is saved to his c:\ in a
predefined format and with a predefined filename.
Anyone?
J. Jespersen> So basically, a user clicks a button, and a report is saved to his c:\ in
> a
> predefined format and with a predefined filename.
Correction: File should just be saved to the servers c:\|||This code will allow you to generate a report, and create a PDF file from it.
You can tweak the parameters to export the format and type you wish:
public static void deliverReport()
{
MyReportingService.ReportingService rs = new ReportingService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Render arguments
byte[] rpt = null;
string reportPath = "/ReportProject1/Report1";
string format = "PDF";
string historyID = null;
string devInfo =@."<DeviceInfo><StartPage>0</StartPage><PageHeight>8.5in</PageHeight><PageWidth>14in</PageWidth></DeviceInfo>";
ParameterValue[] parameters = new ParameterValue[0];
DataSourceCredentials[] credentials = null;
string showHideToggle = null;
string encoding;
string mimeType;
Warning[] warnings = null;
ParameterValue[] reportHistoryParameters = null;
string[] streamIDs = null;
SessionHeader sh = new SessionHeader();
rs.SessionHeaderValue = sh;
rpt = rs.Render(reportPath, format, historyID, devInfo,
parameters, credentials,
showHideToggle, out encoding, out mimeType, out
reportHistoryParameters, out warnings,
out streamIDs);
FileStream stream = File.Create("test.pdf", rpt.Length);
stream.Write(rpt, 0, rpt.Length);
stream.Close();
}
This URL may help you as well:
http://www.csharphelp.com/archives3/archive545.html
Cheers,
Rich
"Jeppe Dige Jespersen" wrote:
> > So basically, a user clicks a button, and a report is saved to his c:\ in
> > a
> > predefined format and with a predefined filename.
> Correction: File should just be saved to the servers c:\
>
>|||Thank you Rich. Works perfectly! :-)
Jeppe Jespersen
Denmark
> This code will allow you to generate a report, and create a PDF file from
> it.
> You can tweak the parameters to export the format and type you wish:
> public static void deliverReport()
> {
> MyReportingService.ReportingService rs = new
> ReportingService();
> rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
> // Render arguments
> byte[] rpt = null;
> string reportPath = "/ReportProject1/Report1";
> string format = "PDF";
> string historyID = null;
> string devInfo => @."<DeviceInfo><StartPage>0</StartPage><PageHeight>8.5in</PageHeight><PageWidth>14in</PageWidth></DeviceInfo>";
> ParameterValue[] parameters = new ParameterValue[0];
> DataSourceCredentials[] credentials = null;
> string showHideToggle = null;
> string encoding;
> string mimeType;
> Warning[] warnings = null;
> ParameterValue[] reportHistoryParameters = null;
> string[] streamIDs = null;
> SessionHeader sh = new SessionHeader();
> rs.SessionHeaderValue = sh;
> rpt = rs.Render(reportPath, format, historyID, devInfo,
> parameters, credentials,
> showHideToggle, out encoding, out mimeType, out
> reportHistoryParameters, out warnings,
> out streamIDs);
> FileStream stream = File.Create("test.pdf", rpt.Length);
> stream.Write(rpt, 0, rpt.Length);
> stream.Close();
> }
> This URL may help you as well:
> http://www.csharphelp.com/archives3/archive545.html
> Cheers,
> Rich
> "Jeppe Dige Jespersen" wrote:
>> > So basically, a user clicks a button, and a report is saved to his c:\
>> > in
>> > a
>> > predefined format and with a predefined filename.
>> Correction: File should just be saved to the servers c:\
>>
Monday, March 19, 2012
generating full script tables and data?
can anyone help? thank you!
-SelAromYour request is one of those "You can get there from here, but..." kind of things. You're obviously comming from another environment where scripting a database is either the easiest or the only way to move it from one server to another. That isn't the case with Microsoft SQL Server.
See the KB Article How to move databases between computers that are running SQL Server (http://support.microsoft.com/default.aspx?scid=kb;en-us;314546) for more details.
If you really want to script out the schema and data, you can do it. Getting Started with SQL-DMO (http://msdn2.microsoft.com/en-us/library/ms144159.aspx) will start you on your way, but I'd strongly recommend using one of the simpler methods!
-PatP|||Your request is one of those "You can get there from here, but..." kind of things. You're obviously comming from another environment where scripting a database is either the easiest or the only way to move it from one server to another. That isn't the case with Microsoft SQL Server.
See the KB Article How to move databases between computers that are running SQL Server (http://support.microsoft.com/default.aspx?scid=kb;en-us;314546) for more details.
If you really want to script out the schema and data, you can do it. Getting Started with SQL-DMO (http://msdn2.microsoft.com/en-us/library/ms144159.aspx) will start you on your way, but I'd strongly recommend using one of the simpler methods!
-PatP
heh well I didn't mean to sound like such a n00b :) but why wouldn't this functionality be natively built in? I'll take a look at your links though, thanks a bunch!
-SelArom
Generating Create Alter Drop Statements
Im using SQL Server 2005 Standard and am trying to get T-SQL to do something that can be done easily through the UI, Genernate SQL Scripts for Create Alter Drop for objects. In the SQL manager its as easy a right clicking a DB Object and going to tasks.
Im wondering if there is a way of doing that through T-SQL.
Thanks in advance!
There is no easy way to do the same from TSQL. Best is to use SMO or SSIS to script out the objects. You could use the built-in metadata function OBJECT_DEFINITION or sp_helptext system stored procedure or query system catalog views. But you will have to code lot of the logic to determine dependencies, generate drop statements or ALTER TABLE etc. So it is best to use one of the methods above.Sunday, February 19, 2012
Generate a cube in Standard Edition
I would like to know if there are some example of how to generate a cube by c#. I am using MS SQL Standard Edition. The AMOAdventureWorks example, just run in Enterprise edition, because of Semi-Additive measures.
Tks!!
Hello! In tools and samples you also have a standard edition version of the Adventure Works cube project
You can probably find it here: c:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks Analysis Services Project
HTH
Thomas Ivarsson
|||Ok, i found it, but I want another thing...
I am working on a project that require me to build cubes programmatically i.e., using AMO object and C#. I am trying to find a sample that builds cubes using C# in Standard Edition.
Tks!!!
|||
I do not know if there is a difference in programatically creating a cube between Standard and Enterprise, but look here:
http://technet.microsoft.com/en-us/library/ms345091.aspx
|||This example is perfect, I am using it, but when I try to execute it, or another example in SQL Standard Edition, the same error occurred in this line, problemas wuth the Semi-Additive Measures :
//--
cube.Update (UpdateOptions.ExpandFull);
//--
The Semi-Additive Measures feature of MS SQL Server 2005 is not supported in its Standard Edition SKU. How do solve this issue? Will I have to by Enterprise Edition SKU ?
This is documented here: http://www.microsoft.com/sql/editions/enterprise/comparison.mspx
Tks!
|||
I just figured this out.
Comment out this stuff in CreateCurrencyRatesMeasureGroup()
//average of children is not allowed.
//meas.AggregateFunction = AggregationFunction.AverageOfChildren;
//last non empty is not allowed.
//meas.AggregateFunction = AggregationFunction.LastNonEmpty;
Generate a cube in Standard Edition
I would like to know if there are some example of how to generate a cube by c#. I am using MS SQL Standard Edition. The AMOAdventureWorks example, just run in Enterprise edition, because of Semi-Additive measures.
Tks!!
Hello! In tools and samples you also have a standard edition version of the Adventure Works cube project
You can probably find it here: c:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks Analysis Services Project
HTH
Thomas Ivarsson
|||Ok, i found it, but I want another thing...
I am working on a project that require me to build cubes programmatically i.e., using AMO object and C#. I am trying to find a sample that builds cubes using C# in Standard Edition.
Tks!!!
|||
I do not know if there is a difference in programatically creating a cube between Standard and Enterprise, but look here:
http://technet.microsoft.com/en-us/library/ms345091.aspx
|||This example is perfect, I am using it, but when I try to execute it, or another example in SQL Standard Edition, the same error occurred in this line, problemas wuth the Semi-Additive Measures :
//--
cube.Update (UpdateOptions.ExpandFull);
//--
The Semi-Additive Measures feature of MS SQL Server 2005 is not supported in its Standard Edition SKU. How do solve this issue? Will I have to by Enterprise Edition SKU ?
This is documented here: http://www.microsoft.com/sql/editions/enterprise/comparison.mspx
Tks!
|||
I just figured this out.
Comment out this stuff in CreateCurrencyRatesMeasureGroup()
//average of children is not allowed.
//meas.AggregateFunction = AggregationFunction.AverageOfChildren;
//last non empty is not allowed.
//meas.AggregateFunction = AggregationFunction.LastNonEmpty;