Skip to Content
0
Former Member
Aug 20, 2012 at 07:45 PM

Crystal Reports VB.Net Issue

40 Views

Moving this from SAP Crystal Reports to here since it is a programming issue(?)

Being new to VB.Net programming with Crystal Reports I have an issue with displaying a report.

The report that I'm trying to display a is on an ASPX page when someone is directed to this page. My code breaks at ExportFormatType function (Error when debugging: Object reference not set to an instance of an object.).

I have tried using Fiddler but it does not show me any prudent information. (In the debug enviroment)

I'm trying to figure out if my report loaded correctly or any help in solving this issue (links, documents, etc).

The code is below. Thanks in advance.

Imports System.Data

Imports System.Data.SqlClient

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Imports CrystalDecisions.Web


Public Class FooTest2

Inherits System.Web.UI.Page

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

Dim cnSQL As New SqlConnection

Dim cmdSQL As New SqlCommand

Dim strConnect As String

Dim da As New SqlDataAdapter

Dim ds As New DataSet

Dim rpt As New ReportDocument


Try

strConnect = ConfigurationManager.ConnectionStrings("xyz").ConnectionString.ToString

cnSQL =New SqlConnection(strConnect)

cmdSQL = New SqlCommand("SELECT X FROM Y", cnSQL)

cmdSQL.CommandType = CommandType.Text

da.SelectCommand = cmdSQL

da.Fill(ds,"ABC")

If ds.IsInitialized Then

If ds.Tables.Count > 0 Then

If ds.Tables(0).Rows.Count > 0 Then

rpt.Load("C:\Users\Me\Documents\visual studio 2010\Projects\ReportFooTest\ReportFooTest\ReportFoo.rpt")

rpt.SetDataSource(ds)

rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, "ReportShow")

End If

End If

End If


Cach ex As Exception


Response.Write(ex.Message)


End Try

End Sub


End

Class