Quantcast
Channel: SQL Server Reporting Services
Viewing all articles
Browse latest Browse all 1418

Web Report Causing An Infinite Loop

$
0
0

I am having problems moving my reports from VS2008 to VS2010.  I have made several WEB reports in VS2008 that use the code below on the load event of the WEB page to provide a data for the report and they all work correctly.  I have to use this method of providing data because I am using several complicated queries that brake the VS2008 and VS2010 wizard.

When I try to convert over to VS2010, the report loading message flashes on the screen and the report never loads.  I have run this code in debug and found that it is causing an infinite loop.  After the code runs, the load event fires again.  I tried adding an exit sub at the end of the code for a test but it has no effect.

Below is a sample of the code that I am using with a simplified query and names.  Any help would be appreciated.



   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' Declare connection string.
        Dim cnString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString.ToString


        ' Declare Connection, command and other related objects
        Dim conReport As New SqlConnection(cnString)
        Dim cmdReport As New SqlCommand()
        Dim drReport As SqlDataReader
        Dim dsReport As DataSet = New DataSet1()

        'Dim dsReport As DataSet = New dsProductReorder

        Try
            ' Open connection
            conReport.Open()

            ' Prepare connection object to get the data through reader and populate into dataset
            cmdReport.CommandType = CommandType.Text
            cmdReport.Connection = conReport
            cmdReport.CommandText = "SELECT * FROM MyTable"


            ' Read data from command object
            drReport = cmdReport.ExecuteReader()

            ' Load data directly from reader to dataset
            dsReport.Tables(0).Load(drReport)

            ' Close reader and connection
            drReport.Close()
            conReport.Close()
       
            ' Provide local report information to viewer
            ReportViewer1.LocalReport.ReportPath = "Report.rdlc"
       
            ' Prepare report data source
            Dim rds As New ReportDataSource()

            ' rds.Name = "dsProductReorder_dtProductReorder"
            rds.Name = "DataSet1_DataTable1"


            rds.Value = dsReport.Tables(0)
            ReportViewer1.LocalReport.DataSources.Add(rds)

            ' Load report viewer
            ReportViewer1.LocalReport.Refresh()

        Catch ex As Exception
            ' Display error message in the output window.
            Debug.Print("The following error occured " & ex.Message)


        Finally
            ' Check if connection is still open then attempt to close it.
            If conReport.State = ConnectionState.Open Then
                conReport.Close()
            End If
        End Try
    End Sub


Viewing all articles
Browse latest Browse all 1418

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>