Skip to Content
0
Former Member
Mar 17, 2009 at 07:36 PM

Visual Studio 2005, embedded Crystal Report problem

23 Views

I am very new at .NET, and this is my first post to this forum.

I've created a Crystal Report within a project using Visual Studio 2005 Professional Edition, on a Windows XP machine. I set the report as the ReportSource for a CrystalReportViewer on the main form. I can see data in the report in design view when I right-click on any of the fields and click "Browse Field Data". But when I preview the report, or run it in the application, all I see are the column headings and report title. I am hoping I am leaving out something obvious. I've researched this for two days without success.

The report's detail section is NOT suppressed, btw.

FYI (although I think it might not be relevant, because I don't see the data when I preview it in Visual Studio either) the report is displayed in the application when a button is clicked, as follows:

Private Sub cmdRunLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRunLog.Click

CrystalReportViewer1.DisplayToolbar = True

cmdRunLog.Text = "Hide Run Log"

cmdUpload.Enabled = False

cmdReports.Enabled = False

cmdManualRun.Enabled = False

CrystalReportViewer1.Visible = True

CrystalReportViewer1.Height = 600

CrystalReportViewer1.Width = 1000

CrystalReportViewer1.Left = 10

Dim strReportSQL As String = "Select * From dbo.PositivePayRunLog"

Dim DA As New SqlDataAdapter(strReportSQL, conPP)

Dim DS As New DataSet

'Variable to assign the report name

Dim strReportPath As String

DA.Fill(DS)

strReportPath = "c:\Positive Pay\PositivePayRunLog.rpt"

If Not IO.File.Exists(strReportPath) Then

_ErrorText = "Unable to locate report file: " & strReportPath

' Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))

GoTo cmdRunLog_Click_Error

End If

Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument

rptDocument.Load(strReportPath)

rptDocument.SetDataSource(DS.Tables(0))

rptDocument.Refresh()

CrystalReportViewer1.ShowRefreshButton = False

CrystalReportViewer1.ShowCloseButton = False

CrystalReportViewer1.ShowGroupTreeButton = False

CrystalReportViewer1.ReportSource = rptDocument

end sub

I'm hoping that this is a common problem with an easy answer 😉

Thanks,

John Sandin