How to Bind Crystal Report to Manually Created Dataset

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();

How to bind a Dataset to CrystalReport in C#

    testdbDataSet ds = new testdbDataSet();

//FETCH FROM ANYWHERE TO a DataTable
DataTable _DtFrmDBPrd = new DataTable();
DataTable _DtFrmDBRgn = new DataTable();

_DtFrmDBPrd = GetDataFrmDBPrd();//Filling the DataTable From DB or any where..
_DtFrmDBRgn = GetDataFrmDBRgn();

ds.Products.Merge(_DtFrmDBPrd);//Both the Data Table should have the same column name and Data Type
ds.Region.Merge(_DtFrmDBRgn);

ReportDocument reportDoc = new ReportDocument();
reportDoc.FileName = "CrystalReport1.rpt";
reportDoc.SetDataSource(ds);

crystalReportViewer1.ReportSource = reportDoc;
crystalReportViewer1.Show();

how to create a crystal report C# without database, by using dataset and datatable and fill this datatable with my own variables?

Not sure what you are asking.

            my_rpt objRpt;
// Creating object of our report.
objRpt = new my_rpt();

DataSet ds = new DataSet("MyDataSet");

DataTable dt = new DataTable("MyDataTable");
ds.Tables.Add(dt);

dt.Columns.Add("id", typeof(int));
dt.Columns.Add("firstname", typeof(string));
dt.Columns.Add("lastname", typeof(string));

dt.Rows.Add(new object[] { 1,"John", "Smith"});
dt.Rows.Add(new object[] { 2, "Mary", "Jones" });
dt.Rows.Add(new object[] { 3, "Harry", "James" });

// Setting data source of our report object
objRpt.SetDataSource(ds);

CrystalDecisions.CrystalReports.Engine.TextObject root;
root = (CrystalDecisions.CrystalReports.Engine.TextObject)
objRpt.ReportDefinition.ReportObjects["txt_header"];
root.Text = "Sample Report By Using Data Table!!";

// Binding the crystalReportViewer with our report object.
crystalReportViewer1.ReportSource = objRpt;

Creating a Crystal Report with dataset populated by list

You dont need to make properties manually.
Just go through the wizard for making a crystal report. It will manage all thing all that need is proper connection with DB and selection of tables.

I think video will help full

How data set with multi table working in asp.net crystal report

My problem is me, i'm use another table in sub report then i need to add that data to sub report



Related Topics



Leave a reply



Submit