Return to Snippet

Revision: 32772
at October 2, 2010 02:40 by pablojaviergarcia


Initial Code
'I figured out how to do this.  I had to piece together help from a few different places, 'but it works.

'1. I added a typed dataset (dsCaseReport) to my project to hold the datatable (dtCaseRpt) 'and tableadapter (taCaseRpt) tied to my SQL stored procedure.
'2. I added a new class (clsCaseRpt) that I use to override the default timeout of taCaseRpt 'since you can't do it via the designer.  This code allows you to change the 'connectionstring timeout to 0 (which is unlimited) before you fill the dataset.  Here is 'the code for that class.
Imports Microsoft.VisualBasic
Namespace dsCaseReportTableAdapters
    Partial Public Class taCaseRpt
        Public Property ConnectionString() As String
            Get
                Return Me.Connection.ConnectionString
            End Get
            Set(ByVal value As String)
                Me.Connection.ConnectionString = value
            End Set
        End Property

        Public Sub SetCommandTimeout(ByVal timeout As Integer)
            If Me.Adapter.InsertCommand IsNot Nothing Then
                Me.Adapter.InsertCommand.CommandTimeout = timeout
            End If

            If Me.Adapter.DeleteCommand IsNot Nothing Then
                Me.Adapter.DeleteCommand.CommandTimeout = timeout
            End If

            If Me.Adapter.UpdateCommand IsNot Nothing Then
                Me.Adapter.UpdateCommand.CommandTimeout = timeout
            End If

            For i As Integer = 0 To Me.CommandCollection.Length - 1
                If Me.CommandCollection(i) IsNot Nothing Then
                    Me.CommandCollection(i).CommandTimeout = timeout
                End If
            Next
        End Sub
    End Class
End Namespace
'3. Then instead of assigning the reportviewer (rvCase) to an Object Data Source on the 'page, I programmatically assign it to the dataset during the page load (or during any other 'sub).  Here is the code for that.  Note: I specify a Case ID parameter when filling my 'dataset.  That is what the intCaseID variable is for.  Also, notice that I call the 'SetCommandTimeout sub with the 0 parameter before filling the dataset.  This overrides the 'default 30 second timeout.  Finally, I assign the dataset as a new datasource to the 'reportviewer control.
        Dim taCaseRpt As New dsCaseReportTableAdapters.taCaseRpt
        Dim dsCaseReport As New dsCaseReport
        Dim intCaseID As Integer = 2
        taCaseRpt.SetCommandTimeout(0)
        taCaseRpt.Fill(dsCaseReport.dtCaseRpt, intCaseID)
        rvCase.LocalReport.DataSources.Clear()
        rvCase.LocalReport.DataSources.Add(New ReportDataSource("dsCaseReport_dtCaseRpt", dsCaseReport.Tables(0)))
'Now it doesn't matter how long it takes for the stored procedure to run, my program will 'wait and the reportviewer will display once it is finished.  I think I covered everything, 'but let me know if you have questions.

Initial URL
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/7af4cd2c-034a-4501-a062-8caaa2e6e924

Initial Description
I have a Report Viewer on an ASPX Form that uses an Object Data Source / Data Set that connects to a SQL Server Database Stored Procedure.  Depending on the parameters sent to the procedure, it will take longer than 30 seconds to run, thus generating the following error:

An error occurred during local report processing.
An error has occurred during report processing.
Exception has been thrown by the target of an invocation.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Initial Title
Set TimeOut to a ReportViewer

Initial Tags


Initial Language
VB.NET