cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports VB.Net Issue

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

It is possible that security is set up so that

("C:\Users\Me\Documents\visual studio 2010\Projects\ReportFooTest\ReportFooTest\ReportFoo.rpt" is not "visible" to IIS.  Your report needs to be in a folder that is part of your website.

-Dell

Former Member
0 Kudos

The page and the report was in the same folder. All I had to do was this...

rpt.Load(Server.MapPath("ReportX.rpt"), OpenReportMethod.OpenReportByTempCopy)

former_member188030
Active Contributor
0 Kudos

When coming back to this page see if the reportobject still exists (persistance) and has not be disposed.

Same thing is applied to the dataset as well.

- Bhushan

Answers (0)