Showing posts with label save. Show all posts
Showing posts with label save. Show all posts

Monday, March 26, 2012

How to use the Render method to save a report directly to disk ?

Hi there,

Is there a way to programmatically save a RS results into Excel format using the render method ?

I had read about that capability but I can't seem to find any sample code on how to do it. Is this a parameter that you have to set in the render method ?

Any suggestion or tips are much appreciated !

Thanks !

Here's one way...

http://sqljunkies.com/WebLog/roman/archive/category/370.aspx

rs -i "C:\RS Script\MyScript.rss" -s http://myserver/reportserver

Here is the code from MyScript.rss. It renders the Product Line Sales report, it's one of the sample reports that comes with RS:

Public Sub Main()
Dim format as string = "EXCEL"
Dim fileName as String = "C:\RS Script\Product Line Sales.xls"
Dim reportPath as String = "/SampleReports/Product Line Sales"

' Prepare Render arguments
Dim historyID as string = Nothing
Dim deviceInfo as string = Nothing
Dim showHide as string = Nothing
Dim results() as Byte
Dim encoding as string
Dim mimeType as string
Dim warnings() AS Warning = Nothing
Dim reportHistoryParameters() As ParameterValue = Nothing
Dim streamIDs() as string = Nothing

results = rs.Render(reportPath, format, _
Nothing, Nothing, Nothing, _
Nothing, Nothing, encoding, mimeType, _
reportHistoryParameters, warnings, streamIDs)

' Open a file stream and write out the report
Dim stream As FileStream = File.OpenWrite(fileName)
stream.Write(results, 0, results.Length)
stream.Close()
End Sub

cheers,

Andrew

|||

Hi andrew,

Thanks for the quick reply !

Yup, that works ! For now I am using this to save my reports to Excel.

I am not sure whether it is actually possible for the Render method to actually save a report to Excel without having to "see the report" or perhaps changing one of the parameters.

Can anyone verify this ?

Thanks.

|||

Hi there,

Glad to hear. Not sure what you mean about having to see the report? If you take a look at running from a URL and specifying the Excel Export option in the query parameters, you should not have to see the report. You would need to either define default parameters or specify required parameters for this to work.

You should be able to automate everything.

cheers,

Andrew

|||

Hi Andrew,

Well the problem with what I am doing is that I need to use the Render method so as not to expose the reporting server URL to outside sources. In other words through ASMX. I am trying not to "render" the report to the browser in Excel format.

So the regular way of rendering a report in the browser is the following:-

Response.ClearContent()

Response.AppendHeader("content-length", result.Length.ToString())

Response.ContentType = mimeType

Response.BinaryWrite(result)

Response.Flush()

Response.Close()

This will render the report in Excel to the browser. I was wondering whether there was a way to save the file as an excel without having to render it to a browser. I am also curious whether there was just more than setting the Format parameter to "EXCEL" and whether there were other parameters that I need to set ? (just like you mentioned in the post)

Thanks

Friday, March 23, 2012

How to use SQL Server Management Studio to save existing SP to source safe?

Wiith SQL Server Management Studio(SQL Server 2005 tools), you can create a project and solution and connect to SourceSafe, then create SQL scripts.These scripts will be able to be checked in/out SourceSafe.

Question is: For existing SQL Server 2000 database, how can I add all existing Stored Procedure to this solution/project and then be able to use sourcesafe to maintain the SP code history?

What I would do is create a database solution/project for each instance in VS2005, script out the objects from the database server and add them to the solution, add the solution to your source control.

Wednesday, March 21, 2012

How to use SQL Server Management Studio to save existing SP to source safe?

Wiith SQL Server Management Studio(SQL Server 2005 tools), you can create a project and solution and connect to SourceSafe, then create SQL scripts.These scripts will be able to be checked in/out SourceSafe.

Question is: For existing SQL Server 2000 database, how can I add all existing Stored Procedure to this solution/project and then be able to use sourcesafe to maintain the SP code history?

What I would do is create a database solution/project for each instance in VS2005, script out the objects from the database server and add them to the solution, add the solution to your source control.

Monday, March 19, 2012

How To use OLE Control like MS Access on SQL Server

I need some help to use an OLE Control which found in MS Access, to save and load files directly .
so Is there any way to implement [OLE] Control with SQL SERVER vs .NET such as VB NEt or C#..
thank youany help please|||how I need a help quickly|||

Quote:

Originally Posted by jooorj

I need some help to use an OLE Control which found in MS Access, to save and load files directly .
so Is there any way to implement [OLE] Control with SQL SERVER vs .NET such as VB NEt or C#..
thank you


No there is no way to do that. You need to use a compiling language.