Hi guys,

I would like to know how to display a report in vb 2005. I've instantiated a crystalreportviewer object, set the Dock prop to Fill, and Report Source prop to the correct data source, but during execution, the report appeares blanck.

Re: Visual Basic Language Crystal Report


But have you added RPT file to your project.Also after adding RPT file you need to Connect to Database and drag and dropped the field on RPT field.
Let me know if it helps you.

Re: Visual Basic Language Crystal Report

Richard Hogan


I am assuming that when in the report designer your report is showing some data, if so then the following code should enable the reportviewer to load and display the data.

Code Snippet

'Import NameSpaces

Imports CrystalDecisions.Shared

Imports CrystalDecisions.CrystalReports.Engine

'Declare Variables

Private myReport As New ReportDocument

Private myConnectionInfo As ConnectionInfo = New ConnectionInfo()

Private Sub RunReports()

'Set Report document = to report document in your solution

myReport = New [Report Name]

'Set database logon info - SQL Server 2000\2005 example

myReport.SetDatabaseLogon("UserName", "Password", "SERVER", "DatebaseName")

'Sets the report source

myCrystalReportViewer.ReportSource = myReport


End Sub

'Loops through all the tables referenced to in your report and sets the database connection info

Private Sub SetDBLogonForReport()

Dim myTableLogOnInfos As TableLogOnInfos = myCrystalReportViewer.LogOnInfo

myConnectionInfo.UserID = "username"

myConnectionInfo.Password = "password"

myConnectionInfo.ServerName = "server"

myConnectionInfo.DatabaseName = "database"

For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos

myTableLogOnInfo.ConnectionInfo = myConnectionInfo


End Sub

Hope this is useful.

Re: Visual Basic Language Crystal Report

Riquel Dong ĘC MSFT


Based on your post, you need to display the data by using CrystalReport control. Please see How To: Create a Crystal Report from ADO.NET Dataset using Visual Basic .NET. This article explains how to report off ADO.NET DataSet using Visual Basic .NET. As you all know DataSet is the core component of distributed application and is explicitly designed for data access independent of any data source. Dataset can be created from variety of sources. Whatever the source is, before reporting off ADO.NET DataSet you must perform the following task:

1. Generate an object for the DataSet.
2. Connect report to DataSet Object.
3. Push data into DataSet Object.
4. Bind report to Windows Forms Viewer to display report with actual data at runtime.

Best regards,