Showing posts with label references. Show all posts
Showing posts with label references. Show all posts

Wednesday, March 7, 2012

Is there any way of Migrating reports from one server to another programmatically thru VB.NET?

Hi,
I wanna know, is there any way of transfering/migrating reports from source server to destination server along with model references programmatically using VB.NET?
If there is a way, can anyone please give me a VB.NET Sample code to achieve my goal?

I will be grateful if anyone help me in this regard!!

Thanks in Advance
Shaun

This isn't exactly what you asked for, but it'll get you started. There are two samples -- One to publish the report and fix up it's data source, and another to grab the model definition and publish it to a server.

In the first sample, you'll need to change the part where the report defintion is loaded from a file to use a call to GetReportDefinition() (http://msdn2.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswebservice.rsmanagementservice2005.reportingservice2005.getreportdefinition.aspx)

Later on in the first sample, the the Data Source reference should point to your model instead of the data source in the code itself.

In the second sample, the code reads a model and then republishes it to the *same* server. Create another instance of the web reference to the web service which points to the "other" machine, and use IT to publish to the new destination server.

private void button1_Click(object sender, EventArgs e)
{

SampleApp.localhost.ReportingService2005 rs = new SampleApp.localhost.ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

try
{
byte[] reportDefinition;
Warning[] warnings;

FileStream stream = File.OpenRead(@."C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Report Samples\AdventureWorks Sample Reports\Company Sales.rdl");
reportDefinition = new Byte[stream.Length];
stream.Read(reportDefinition, 0, (int)stream.Length);
stream.Close();

// Create a report which utilizes a pre-existing shared data source

// Optionally, set properties on the report by replacing the null in the last parameter of
// CreateReport with an array of properties

localhost.Property[] reportProps = new PropertyDevil;
reportProps[0] = new Property();
reportProps[0].Name = "PageHeight";
reportProps[0].Value = "279.4";
reportProps[1] = new Property();
reportProps[1].Name = "PageWidth";
reportProps[1].Value = "215.9";
reportProps[2] = new Property();
reportProps[2].Name = "TopMargin";
reportProps[2].Value = "12.7";
reportProps[3] = new Property();
reportProps[3].Name = "BottomMargin";
reportProps[3].Value = "12.7";
reportProps[4] = new Property();
reportProps[4].Name = "LeftMargin";
reportProps[4].Value = "12.7";
reportProps[5] = new Property();
reportProps[5].Name = "RightMargin";
reportProps[5].Value = "12.7";


warnings = rs.CreateReport("Company Sales", "/AdventureWorks Sample Reports", true, reportDefinition, reportProps);

if (warnings!=null)
{
Console.WriteLine("Warnings occured when creating report");
foreach (Warning warning in warnings)
Console.WriteLine("\t" + warning.Code + ": " + warning.Message);
}

try
{
// Report was created, now fix up datasource reference to make sure report points at correct ds
DataSourceReference reference = new DataSourceReference();
DataSource[] dsarray = new DataSource[1];
DataSource ds = new DataSource();
reference.Reference = "/Data Sources/AdventureWorks";
ds.Item = (DataSourceReference)reference;
ds.Name = "AdventureWorks";
dsarray[0] = ds;
rs.SetItemDataSources("/AdventureWorks Sample Reports/Company Sales", dsarray);
}
catch (SoapException ex)
{
Console.WriteLine("Error Code: " + ex.Detail["ErrorCode"].InnerXml);
Console.WriteLine("Message: " + ex.Detail["Message"].InnerXml);
}


}

....and here's how to get the model:

private void button2_Click(object sender, EventArgs e)
{
localhost.ReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
//To hold SMDL as byte array
Byte[] modelDef;


//Work on pre-published Model

//... if it's not already there. See CreateDataSource.cs for more inforamtion

//Get definition of model, save in byte array
modelDef = rs.GetModelDefinition("/Models/Adventure Works");

//Publish Model

try
{
rs.CreateModel("CopyOfAdventureWorksModel", "/Models", modelDef, null);
}

catch (System.Web.Services.Protocols.SoapException ex)
{
Console.WriteLine(ex.Detail.InnerXml.ToString());
}
}

|||Russell, thank you very much for your patience and response!!
I will get back to you at the earliest, coz I need to give this code to my client!!!
Will reply to you after he gets back to me!!

Friday, February 24, 2012

Is there any performance differences between function type IF and TF?

I could not found more references in BOA about functions that return table.
Does anybody know if there is any performance differences between these two
type of functions?
IF = Inlined table-function
TF = Table function
Thanks,
Lijun
Lijun Zhang (nospam@.nospam.nospam) writes:
> I could not found more references in BOA about functions that return
> table. Does anybody know if there is any performance differences between
> these two type of functions?
> IF = Inlined table-function
> TF = Table function
Yes, there is.
An inline function is in fact not a function at all; it is a macro. The
optimiser pastes the text of the function into the query and optimizes
the result.
A multi-step function returns data to a table variable, and the result
of the function is opaque to the optimizer.
Thus, in the former case the optimizer have more information, and
thus better possibilities to create a better execution plan.
But sometimes it can be too much information, so in fact it leads
to poorer performance. But in the long run, inline functions will
give you better performance.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
|||Yes, there may be a significant difference, although of course that
depends on exactly what you are doing.
Despite the similar syntax *inline* table-valued functions are
implemented very differently from *multi-statement* table-valued
functions.
A inline table-valued function consists of a single query that works
very like a view. That is, when the function is referenced in another
query the SQL from both the calling query and the function itself is
considered together so as to arrive at an optimal execution plan.
With a multi-statement table-valued function that kind of optimization
isn't possible. In a multi-statement function the function code is
executed more like a stored procedure and then a result returned to the
calling code for further processing.
If you want to encapsulate a single query in a function then use an
inline TVF, or use a view.
If you need to put multiple statements in a function then you'll have
to use a multi-statement TVF.
David Portas
SQL Server MVP

Is there any performance differences between function type IF and TF?

I could not found more references in BOA about functions that return table.
Does anybody know if there is any performance differences between these two
type of functions?
IF = Inlined table-function
TF = Table function
Thanks,
LijunLijun Zhang (nospam@.nospam.nospam) writes:
> I could not found more references in BOA about functions that return
> table. Does anybody know if there is any performance differences between
> these two type of functions?
> IF = Inlined table-function
> TF = Table function
Yes, there is.
An inline function is in fact not a function at all; it is a macro. The
optimiser pastes the text of the function into the query and optimizes
the result.
A multi-step function returns data to a table variable, and the result
of the function is opaque to the optimizer.
Thus, in the former case the optimizer have more information, and
thus better possibilities to create a better execution plan.
But sometimes it can be too much information, so in fact it leads
to poorer performance. But in the long run, inline functions will
give you better performance.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Yes, there may be a significant difference, although of course that
depends on exactly what you are doing.
Despite the similar syntax *inline* table-valued functions are
implemented very differently from *multi-statement* table-valued
functions.
A inline table-valued function consists of a single query that works
very like a view. That is, when the function is referenced in another
query the SQL from both the calling query and the function itself is
considered together so as to arrive at an optimal execution plan.
With a multi-statement table-valued function that kind of optimization
isn't possible. In a multi-statement function the function code is
executed more like a stored procedure and then a result returned to the
calling code for further processing.
If you want to encapsulate a single query in a function then use an
inline TVF, or use a view.
If you need to put multiple statements in a function then you'll have
to use a multi-statement TVF.
David Portas
SQL Server MVP
--

Is there any performance differences between function type IF and TF?

I could not found more references in BOA about functions that return table.
Does anybody know if there is any performance differences between these two
type of functions?
IF = Inlined table-function
TF = Table function
Thanks,
LijunLijun Zhang (nospam@.nospam.nospam) writes:
> I could not found more references in BOA about functions that return
> table. Does anybody know if there is any performance differences between
> these two type of functions?
> IF = Inlined table-function
> TF = Table function
Yes, there is.
An inline function is in fact not a function at all; it is a macro. The
optimiser pastes the text of the function into the query and optimizes
the result.
A multi-step function returns data to a table variable, and the result
of the function is opaque to the optimizer.
Thus, in the former case the optimizer have more information, and
thus better possibilities to create a better execution plan.
But sometimes it can be too much information, so in fact it leads
to poorer performance. But in the long run, inline functions will
give you better performance.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp|||Yes, there may be a significant difference, although of course that
depends on exactly what you are doing.
Despite the similar syntax *inline* table-valued functions are
implemented very differently from *multi-statement* table-valued
functions.
A inline table-valued function consists of a single query that works
very like a view. That is, when the function is referenced in another
query the SQL from both the calling query and the function itself is
considered together so as to arrive at an optimal execution plan.
With a multi-statement table-valued function that kind of optimization
isn't possible. In a multi-statement function the function code is
executed more like a stored procedure and then a result returned to the
calling code for further processing.
If you want to encapsulate a single query in a function then use an
inline TVF, or use a view.
If you need to put multiple statements in a function then you'll have
to use a multi-statement TVF.
--
David Portas
SQL Server MVP
--