• This is the basics of the code that I use. I would have built from other code that I found on the internet. I will post the original link if I can find it.

    Private Function Generate_CC_Mgr_Report(ByVal reportPath As String, _

    ByVal Period As Integer, _

    ByVal DTU_Key As Integer, _

    ByVal strFilename As String) As Windows.Forms.DialogResult

    ' strReport = The full path of the report on the server e.g. /FolderName1/FolderName2/rpt_TA_CC_Manager_Summary

    ' Period = Report parameter

    ' DTU_Key = Report parameter

    ' strFilename = The name that you want to call teh saved report e.g. C:\MyReports\CC_MGR_Report_<Period>_<DTU_Key>.pdf

    Generate_CC_Mgr_Report = Windows.Forms.DialogResult.Yes

    ' Render Formats

    'XML : XML file with report data

    'CSV : CSV (comma delimited)

    'IMAGE: TIFF(file)

    'PDF : Acrobat (PDF) file

    'RGDI: Remote(GDI + file)

    'HTML4.0 : Web page for IE 5.0 or later (.htm)

    'HTML3.2 : Web page for most web browsers (.htm)

    'MHTML: Web(archive)

    'EXCEL: Excel()

    Dim OldCursor As Cursor = Me.Cursor

    Dim rs As New ReportExecutionService()

    Dim result As Byte() = Nothing

    Dim format As String = "PDF"

    Dim historyID As String = Nothing

    Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"

    Dim Parameters() As ParameterValue

    Dim credentials As DataSourceCredentials() = Nothing

    Dim showHideToggle As String = Nothing

    Dim encoding As String = ""

    Dim mimeType As String = ""

    Dim warnings As Warning() = Nothing

    Dim reportHistoryParameters As ParameterValue() = Nothing

    Dim streamIDs As String() = Nothing

    Dim execInfo As New ExecutionInfo

    Dim execHeader As New ExecutionHeader()

    Dim SessionId As String

    Dim extension As String = "PDF"

    My.Application.DoEvents()

    Me.Cursor = Cursors.WaitCursor

    Try

    rs.Credentials = System.Net.CredentialCache.DefaultCredentials

    ' Location of the report Execution asmx file on the Report Server

    rs.Url = "http://<REPORTSERVERNAME>/reportserver/ReportExecution2005.asmx"

    rs.Timeout = 600000 ' 10 minutes

    ' Prepare report parameters.

    ReDim Parameters(1)

    Parameters(0) = New ParameterValue()

    Parameters(0).Name = "Period"

    Parameters(0).Value = Period

    Parameters(1) = New ParameterValue()

    Parameters(1).Name = "DTU_Key"

    Parameters(1).Value = DTU_Key

    rs.ExecutionHeaderValue = execHeader

    execInfo = rs.LoadReport(reportPath, historyID)

    rs.SetExecutionParameters(Parameters, "")

    SessionId = rs.ExecutionHeaderValue.ExecutionID

    ' Render report to selected format

    result = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)

    ' Write the contents of the report to a file.

    Dim stream As FileStream = File.Create(strFilename, result.Length)

    stream.Write(result, 0, result.Length)

    stream.Close()

    Catch ex As Exception

    Generate_CC_Mgr_Report = MyMessageBox(Me.Name, "Error Running Report '" & reportPath & "'" & vbCrLf & ex.Message & vbCrLf & vbCrLf & "Click YES to Continue, NO to Abort", "Error Running Report", MessageBoxIcon.Error, MessageBoxButtons.YesNo)

    Finally

    Me.Cursor = OldCursor

    End Try

    End Function