SSRS automatically run report & save pdf output to c: | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

SSRS automatically run report & save pdf output to c:

Good day, I need help.
I normally run a report via url and add the &rs:Format=PDF to open file directly in PDF format.
But i now need to automatically run the report onclick of an html button & save pdf to c:
Is this possible, how? Regards

You can do it, exporting a report is an on-demand task that you perform when the report is open in a browser window. If you want to automate an export operation (for example, to export a report to a shared folder as a specific file type on a recurring schedule), create a subscription that delivers the report to a shared folder, see too.

use only below statement
Public Shared Function ExportReport(ByVal URL As String) As String Dim path As String = "C:genertaion.PDF" Try
Dim Req As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create(URL), System.Net.HttpWebRequest)
Req.Credentials = System.Net.CredentialCache.DefaultCredentials
Req.Method = "Get"
Dim objResponse As System.Net.WebResponse = Req.GetResponse()
Dim fs As New System.IO.FileStream(path, System.IO.FileMode.Create)
Dim stream As System.IO.Stream = objResponse.GetResponseStream()
Dim buf As Byte() = New Byte(1023) {}
Dim len As Integer = stream.Read(buf, 0, 1024)
While len > 0
fs.Write(buf, 0, len)
len = stream.Read(buf, 0, 1024)
End While
Catch e As Exception
return e.Message
End Try return path
End Function
Public Shared Function SendMail(ByVal URL As String) As String Dim username As string = "ic"
Dim password As string = "icc"
Dim domain As string = "za"
Dim path As String
path =ExportReport(URL)
Dim message As New System.Net.Mail.MailMessage("","","report.","See the attached.") Dim data As New System.Net.Mail.Attachment (path, System.Net.Mime.MediaTypeNames.Application.Octet)
‘Add the file attachment to this e-mail message.
message.Attachments.Add(data) Dim client As new System.Net.Mail.SmtpClient("srv19-za199")
‘Credentials are necessary if the server requires the client
‘to authenticate before it will send e-mail on the client’s behalf.
client.UseDefaultCredentials = false
client.Credentials = New System.Net.NetworkCredential("ic", "icc","za")
catch e as exception
return e.Message
end try
End Function

Apoogies, I have not seen your reply.
I will give it a go – would be great if i could get it going.
I in the mean time post a new ques – to try & use web services


Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |