I created a rdl report using SQL Server Business Intelligence Development Studio 2008 R2.
I used a simple query
Select top 10 id from login_user where client_id =3
and the preview show the data as below
Then i create a c# window application with report viewer and a command button. on button click I wrote the below code
SqlConnection conn = new SqlConnection(connstring);
DataSet dataset = new DataSet();
conn.Open();
sqlcomm = new SqlCommand("Select top 10 id from login_user where client_id = "+ 32, conn);
SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlcomm);
dataAdapter.Fill(dataset);
this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + "\\Report1.rdl";
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("TotalSale", dataset.Tables[0]));
this.reportViewer1.RefreshReport();
It executed successfully but the report viewer is not showing the report it is giving a message
a datasource instance has not been supplied for the datasource
it is because i am using .rdl? only rdlc work with .net? I am stucked here.
In this line
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("TotalSale", dataset.Tables[0]));
replace "TotalSale" with "DatSet1"
because your data set name in report is DataSet1.