Skip to Content
0
Former Member
Dec 03, 2014 at 09:38 AM

ReportDocument.SetDataSource throws excption when running from setup

81 Views

Hello SAP,

I am creating an application in which I required to creating a crystal report.

To assign the data Table to crystal report I had written following code.

Dim frmPreview As New frmPreview With {.strReportLocation = PstrReportFilename2_Work, .strReportDbLoacation = PstrDatabaseName2_Work}

Dim Report As New ReportDocument

Dim oledbConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & frmPreview.strReportDbLoacation & ";User Id=admin;Password=;"

Dim ConDb As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(oledbConnectionString)

ConDb.Open()

Dim dataAdapter1 As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM TK3320530", ConDb)

Dim dataTable As New DataTable("Report2")

dataAdapter1.Fill(dataTable)

Report.Load(frmPreview.strReportLocation)

Report.SetDataSource(dataTable)

frmPreview.CrystalReportViewer1.ReportSource = Report

This code works fine in development environment but when I build it and run from .exe file.

It throws the exception. at Report.SetDataSource(dataTable) statement

I am attaching a screenshot of stack trace and error message. Please take a moment to review it.

Thanks,

Rudresh Bhatt

Attachments