PDA

Click to See Complete Forum and Search --> : Simple Crystal Report Question


dogboydelta
Jan 19th, 2007, 10:11 AM
I'm moving my Crystal reports questions here from VB.NET

Here's the code I'm currently using:



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)
Dim formula As String = ""
myCrystalReport.RecordSelectionFormula = formula
myCrystalReportViewer1.DisplayGroupTree = False
myCrystalReportViewer1.Zoom(100)
myCrystalReport.SetDataSource(dt)
myCrystalReportViewer1.ReportSource = myCrystalReport
con.Close()



The error occurs on the myCrystalReport.SetDataSource(dt), it says
'The Report has no tables'.

What can I do about this? The messagebox shows that 24 lines are returned from the select statement, so the data is there, but I guess the report doesn't have a table? How can I add one? Please help!