Click here to Skip to main content
12,406,322 members (68,138 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0
Hi friends
I want to fill dataReportViewer with DataTable but i don't know how can i do this.
Could you help me?
Posted 2-Feb-13 20:09pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
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
Krunal Rohit 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160726.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100