Code to bind .xsd typed dataset (from SQL DB datasource) to crystal report?

ridhwaans

Active member
Joined
Jun 1, 2012
Messages
34
Programming Experience
3-5
Hi,
In my project, Ive got a dataset acquired from a SQL database connection
here is a picture

Untitled.png

The dataset is fairly small, and it has got four tables (i.e. table1, table2, table3, table4)

Now the case is that I am trying to bind that dataset to one of my crystal reports 'crReport.rpt' (that is supposed to load through a crystal report viewer) in code in the form load event
Suppose, i have an instance of this dataset ('myDataSet.xsd'), how do I bind it to my crystal report using the report.setDataSource property?


I keep getting invalid file path error and loadsavefile exceptions

I know this is one way to bind the dataset using code:
Dim crReport As New ReportDocument
Dim ds1 As New DataSet

Dim cmd1 As New MySqlCommand("SELECT * FROM table1", conn)
da1.SelectCommand = cmd1
da1.Fill(ds1, "Table1")

crReport.Load(strReportPath)
crReport.SetDataSource(ds1)
CrystalReportViewer1.ReportSource = crReport

^ but what I wish to do is something like

Dim dataset1 as new dataset
dataset1 = me.myDataSet or Dim dataset1As DataSet = DataSetConfiguration.myDataSet
crReport.SetDataSource(dataset1)

Anyways, how do you implement this ? Please advise

Thanks
 
Back
Top