How to bind crystal report to manually created DataSet

There is only way out. As suggested by rosado. Little bit explained
1. CReate a RPT File.
2. Create a XSD with the desired columns.
3. Drag drop the columns on the rpt. Format it as required.
4. Now create connection, use adapter to fill that dataset.
5. Filling u dataset will automatically fill the report columns.

Below is a sample code from one of mine project.

Invoice invoice = new Invoice(); // instance of my rpt file
var ds = new DsBilling();  // DsBilling is mine XSD
var table2 = ds.Vendor;
var adapter2 = new VendorTableAdapter();
adapter2.Fill(table2);                   

var table = ds.Bill;
var adapter = new BillTableAdapter();
string name = cboCustReport.Text;
int month = int.Parse(cboRptFromMonth.SelectedItem.ToString());
int year = int.Parse(cboReportFromYear.SelectedItem.ToString());
adapter.Fill(table, name,month,year);

ds.AcceptChanges();

invoice.SetDataSource(ds);
crystalReportViewer1.ReportSource = invoice;
crystalReportViewer1.RefreshReport();

Leave a Comment