Click here to Skip to main content
15,120,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends
I want to fill dataReportViewer with DataTable but i don't know how can i do this.
Could you help me?
Posted

1 solution

   
Comments
Elham.Deljooei 3-Feb-13 2:41am
   
this my code:

SqlDataAdapter adp = new SqlDataAdapter("Report",con);
adp.SelectCommand = new SqlCommand();
adp.SelectCommand.CommandType = CommandType.StoredProcedure;
DataTable dtbl=new DataTable();
dtbl.TableName="DataTable1";

adp.SelectCommand.Parameters.AddWithValue("@clrk_Name", txtNameReport.Text);
adp.SelectCommand.Parameters.AddWithValue("@clrk_Family",txtFamilyReport.Text);
adp.SelectCommand.Parameters.AddWithValue("@clrk_MelliCode",txtMelliCodeReport.Text);
adp.SelectCommand.Parameters.AddWithValue("@AzTarikh",txtMelliCodeReport.Text);
adp.SelectCommand.Parameters.AddWithValue("@Ela", txtElaReport.Text);
adp.Fill(dtbl);
ReportDataSource source = new ReportDataSource("DataTable1",dtbl);
reportViewer1.LocalReport.DataSources.Add(source);
when i run my project, i get this eeror

Error 1 The tablix ‘Tablix2’ is in the report body but the report has no dataset. Data regions are not allowed in reports without datasets. D:\Project\evaluation\WindowsFormsApplication1\WindowsFormsApplication1\Report1.rdlc WindowsFormsApplication1
[no name] 3-Feb-13 2:46am
   
SqlDataAdapter adp = new SqlDataAdapter("Report",con);
adp.SelectCommand = new SqlCommand();
adp.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
DataTable dt = new DataTable("DataTable");
adp.Fill(ds, "DataTable");
Elham.Deljooei 3-Feb-13 2:57am
   
i did it but i get it error :-(
Elham.Deljooei 3-Feb-13 4:37am
   
could you help me?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900