Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Form - Data Set and Crystal Report

Status
Not open for further replies.

mydisney

Programmer
May 7, 2007
55
US
I have an application that reads from a data base table and fills a DataSet and consequently binds to a DataGrigView. Now I need to add a Crystal Report Viewer to the same form and display the query result.

I have defined my data set in the code (no user controls from tool box). When I try to fill the Crystal Report it only show the heading and tells me "The Report has no tables". Do I need to define a schema for my CR? I tried to use the database expert but I do not have a data set to link to (since defined in code). Can anybody help?


Code:
Dim mySqlCommand As New SqlCommand("sp_GetjobTable", ServerConnection)
Dim mySqlAdapter = New SqlDataAdapter(mySqlCommand)
Dim mySqlDataSet As New DataSet
Dim JobTable As New DataTable

mySqlAdapter.fill(mySqlDataSet, "JobTable")
DataGridView1.DataSource = mySqlDataSet.Tables("JobTable")
myCrystalReport.SetDataSource(mySqlDataSet.Tables("Jobtable"))
MyCrystalReportViewer.ReportSource = myCrystalReport

Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ConfigureCrystalReports()
End Sub

Code:
Private Sub ConfigureCrystalReports()

End Sub
 
Found the answer:

Code:
// Using a previously defined Dataset (ds) with i tables
ReportDocument rd = new ReportDocument();
rd.Load(strReportPath);

for (int i = 0; i < ds.Tables.Count; i++)
{
     rd.Database.Tables[i].SetDataSource(ds.Tables[i]);
}

crystalReportViewer1.ReportSource = rd;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top