Skip to Content
0
Former Member
May 09, 2010 at 06:50 AM

Error when run crystal report viewer page

170 Views

Hi I created form using vb 2008 contains crystalreportviewer and in load sub I wrote the following code to show the report:

Dim r_select As String

Dim MyReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

r_select = "Select Innovative_Form.* from Innovative_Form"

Dim da As OleDbDataAdapter = New OleDbDataAdapter(r_select, System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ToString())

Dim da33 As New System.Data.DataSet

da.Fill(da33, "DataTable1")

MyReport.Load(Server.MapPath("CrystalReport.rpt"))

MyReport.SetDataSource(da33)

Me.CrystalReportViewer1.ReportSource = MyReport

Me.CrystalReportViewer1.DisplayGroupTree = False

Me.CrystalReportViewer1.DataBind()

Me.CrystalReportViewer1.ShowFirstPage()

'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

End Sub

when run I got the following error

Server Error in '/Innovation Last Version-10-1-10' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 34:

Line 35:

Line 36: Dim da As OleDbDataAdapter = New OleDbDataAdapter(r_select, System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ToString())

Line 37:

Line 38:

Source File: C:\Users\kisruser\Desktop\PROJECTS\Innovate Project\Innovation Last Version-10-1-10\Report.aspx.vb Line: 36

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]

Report.Page_Load(Object sender, EventArgs e) in C:\Users\kisruser\Desktop\PROJECTS\Innovate Project\Innovation Last Version-10-1-10\Report.aspx.vb:36

System.Web.UI.Control.OnLoad(EventArgs e) +99

System.Web.UI.Control.LoadRecursive() +50

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016

SO WHAT IS THE PROBLEM?????