I'm just starting out with crystal reports, it looks really cool but I'm having difficulty. As my first project I just want to bind a simple table to a report and view it. Here is my code:
Dim myCrystalReport As New CrystalReport1
Dim con As New SqlClient.SqlConnection
Dim com As New SqlClient.SqlCommand
Dim sqlapa As New SqlClient.SqlDataAdapter
Dim dt As New DataTable
con.ConnectionString =
"..."
con.Open()
com.Connection = con
com.CommandType = CommandType.Text
com.CommandText =
"select webuserid, username from twebuser"
sqlapa.SelectCommand = com
sqlapa.Fill(dt)
MessageBox.Show(dt.Rows.Count.ToString)
myCrystalReportViewer1.DisplayGroupTree = False
myCrystalReportViewer1.Zoom(100)
myCrystalReport.SetDataSource(dt)
myCrystalReportViewer1.ReportSource = myCrystalReport
con.Close()
The error is occuring on this line:
myCrystalReport.SetDataSource(dt)
The error states "The Report has no tables".
I get 24 results on the messagebox so I know the data is being properly read into the datatable. Please help.