How to bind crystal report to manually created DataSet How to bind crystal report to manually created DataSet asp.net asp.net

How to bind crystal report to manually created DataSet


There is only way out. As suggested by rosado. Little bit explained1. 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 filevar ds = new DsBilling();  // DsBilling is mine XSDvar 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();


try like this...

DataSet ds = new DataSet();   oleAdapter.Fill(ds);   ReportDocument rpt = new ReportDocument();   rpt.load();   rpt.Database.Tables[0].SetDataSource(ds.Tables[0]);    this.crystalReportViewer1.ReportSource = rpt;


Add a dataset object (.xsd) in visual studio and fill it with one or many datatables containing the SAME field names you got on your DataSet ds = new DataSet();

Then go to your .rpt file: database fields -> database expert - > project data -> ADO.Net DataSets, then select the dataset you just created and design the report as you want.

Use the report as usual.

myReport.SetDataSource(ds);