on 08-20-2012 8:45 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.