SQL Server Performance

SSRS automatically run report & save pdf output to c:

Discussion in 'SQL Server 2005 Reporting Services' started by Ismailc, Dec 1, 2009.

  1. Ismailc New Member

    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
  2. satya Moderator

    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 http://msdn.microsoft.com/en-us/library/ms159264(SQL.90).aspx too.
  3. freezea New Member

    use only below statement

    Public Shared Function ExportReport(ByVal URL As String) As String

    Dim path As String = "C:genertaion.PDF"

    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("[email protected]","[email protected]","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.

    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
  4. Ismailc New Member

    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

Share This Page