Hello,
I would like to use a Crystal Report based on a dataset and a SQL query.
When I use a dataset created with the assistant, it works.
But when I create a dataset with code, using a sql query, the Crystal report is empty.
Is the code below correct ?
Thanks for your help.
CRV01 is a Crystal report viewer used to display the report.
CR01.RPT is the Crystal report created with the assistant.
I would like to use a Crystal Report based on a dataset and a SQL query.
When I use a dataset created with the assistant, it works.
But when I create a dataset with code, using a sql query, the Crystal report is empty.
Is the code below correct ?
Thanks for your help.
CRV01 is a Crystal report viewer used to display the report.
CR01.RPT is the Crystal report created with the assistant.
VB.NET:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Public cs As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
Public dr As String = "C:\_01\"
Public db As String = "pro.mdb"
Public tb1 As String = "Table1"
Public cn As String = cs & dr & db
Public sql As String
Private Sub Form2_Load
sql = "SELECT * FROM Table1"
Dim Dta As New OleDb.OleDbDataAdapter(sql, cn)
Dim Dts As New DataSet("result")
Dta.Fill(Dts)
Dim crd As New ReportDocument
crd.Load("c:\VBN\CR01.RPT")
crd.SetDataSource(Dts)
CRV01.ReportSource = crd
CRV01.Refresh()
End Sub