2012-01-06 125 views

回答

2

使用報告服務Web服務。一個漂亮的帖子裏這樣做是:http://geekswithblogs.net/bsherwin/archive/2007/04/29/112094.aspx

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) 

Dim stream As FileStream = File.Create("C:\My Reports\report.pdf", results.Length) 
stream.Write(results, 0, results.Length) 
stream.Close() 
+0

謝謝,但我需要它的WinForms .............. – 2012-01-06 14:52:54

+0

我更新我的回答,只是把結果寫入文件,而不是在瀏覽器中顯示它。 – KMan 2012-01-06 15:16:15

+0

再次感謝,但它從哪裏得到哪些報告要寫成PDF? – 2012-01-06 15:19:45