Geeks With Blogs
Brian Sherwin's Blog Moving at the Speed of .Net

This post is primarily for Steve since he has been bugging me about it.  (Forgive the VB, but this is what I did the demos in).  Steve doesn't like doing SQLRS, but personally, I'd like to do more of it.  I just can't seem to come up with any clients that want to do it.

Any way, here is the process of creating the PDF without using the Report Viewer.

Create a reference to the Reporting Services Web Services then get a variable reference for it:

Dim ws As New SQLRS.ReportingService
Dim creds As New System.Net.NetworkCredential

Next set the authentication for the web service:

creds.UserName = "RSUser"
creds.Password = "SomePassword"
ws.Credentials = creds

Finally, set some of the web service variables for how you want the data rendered.  You don't have to set all of these, but you will have to pass them all in, so I just like to be clear about what I am doing:

Dim result() As Byte
Dim report As String = "/Sample Reports/Sales Order Detail"
Dim format As String = "PDF"
Dim historyid As String = Nothing
Dim devinfo As String = ""
Dim credentials() As SQLRS.DataSourceCredentials = Nothing
Dim showhide As String = Nothing
Dim encoding As String
Dim mimetype As String
Dim warnings() As SQLRS.Warning = Nothing
Dim reporthistoryparams As SQLRS.ParameterValue() = Nothing
Dim streamid() As String = Nothing
Dim sh As New SQLRS.SessionHeader
ws.SessionHeaderValue = sh

Next, get the result from the web service:

result = ws.Render(report, format, historyid, devinfo, parameters, _
            credentials, showhide, encoding, mimetype, reporthistoryparams, _
            warnings, streamid)

And stuff it into the workflow (in this case, open the PDF in your favorite browser):

Response.ClearContent()
Response.ContentType = "application/pdf"
Response.BinaryWrite(result)
Response.Flush()

And for the record Steve...No, I will not convert this to C# for you, and I feel no shame to post VB code.

Posted on Sunday, April 29, 2007 10:04 PM | Back to top

Copyright © Brian Sherwin | Powered by: GeeksWithBlogs.net | Join free