-
Dataset problem
Hello everybody,
I added a DataSet ReportsDataSet.xsd in my project and added one DataTable named dtClients with 9 columns. I added a crystal report and designed it using this data table. Now I want to fill the data table to show the results in crystal reports. Following is the code I am using to fill the data table.
Code:
ReportsDataSet ds = new ReportsDataSet();
DataRow dr;
for (int i = 0; i < dtClients.Rows.Count; i++)
{
dr = ds.dtClients.NewRow();
dr["ClientNumber"] = dtClients.Rows[i]["ClientNumber"].ToString();
dr["From"] = dtClients.Rows[i]["From"].ToString();
dr["ClientName"] = dtClients.Rows[i]["ClientName"].ToString();
dr["Person"] = dtClients.Rows[i]["Person"].ToString();
dr["Address"] = dtClients.Rows[i]["Address"].ToString();
dr["Near"] = dtClients.Rows[i]["Near"].ToString();
dr["Phone"] = dtClients.Rows[i]["Phone"].ToString();
dr["Cell"] = dtClients.Rows[i]["Cell"].ToString();
dr["Email"] = dtClients.Rows[i]["Email"].ToString();
ds.dtClients.Rows.Add(dr);
ds.dtClients.AcceptChanges();
}
But the data doesn't show up in the report. I need to know what I am doing wrong. Any idea?
Thanks.
-
Re: Dataset problem
Is the report bound to that DataSet? I'll wager not, given that it's create new in that code.
I don't use CR but, in general, either you need to add the DataSet in the designer and bind it to the report in the designer, or else you need to create the DataSet in code and bind it to the report in code.
-
Re: Dataset problem
I have created DataSet using the designer and I added a Datatable in the data set using the designer, and I bound the crystal report designer directly with the dataset. But I am populating the DataSet through code as mentioned above.
Thanks.