Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am trying to generate report during runtime using some parameters.But I am getting this error
“a data source instance has not been supplied for the data source dataset1”
I have done the following.
1. Created Dataset with query like SELECT * FROM Sreenath where Sree=@Sree. This Sreenath table has got Sree and ID as columns.
2. Tagged it to Report1.rdlc.
3. Attached Report1.rdlc to a reportviewer.
4. While runtime I trying to refresh the report in following ways...
First way:
C#
ReportParameter lObjParam = new ReportParameter("Sree", aStrSree);
ReportParameter[] lArrParam = { lObjParam };
ReportViewer3.LocalReport.SetParameters(lArrParam);
ReportViewer3.LocalReport.Refresh();

Second Way
C#
string lStrReportPath = ReportViewer3.LocalReport.ReportPath;
DataSet2.SreenathDataTable lDS = new DataSet2.SreenathDataTable();
DataSet2TableAdapters.SreenathTableAdapter lAdapter = new DataSet2TableAdapters.SreenathTableAdapter();
lDS = lAdapter.GetDataIds(aStrSree);
int lIntResult = lAdapter.Fill(lDS, aStrSree);
ReportDataSource lDTSource = new ReportDataSource("DataSet2_Sreenath", (DataTable)lDS);
ReportViewer3.LocalReport.DataSources.Clear();
ReportViewer3.LocalReport.ReportPath = lStrReportPath;
ReportViewer3.LocalReport.DataSources.Add(lDTSource);
ReportViewer3.LocalReport.Refresh();

What is that I am doing wrong here…
Any help over here please.
Posted
Updated 2-Aug-11 18:50pm
v2

Solved..Please chek out..

http://www.eggheadcafe.com/community/aspnet/17/10340545/issue-in-retting-reportviewer-parameters-in-aspnet-2010.aspx
 
Share this answer
 
now you try this:-
sqlconnection con=new sqlconnection(//your connection string);
sqlcommand cmd=new sqlcommand("SELECT * FROM Sreenath where Sree=@Sree",con);
cmd.Parameters.AddWithValue("@Sree",//your value);
sqldataadapter adapter=new sqldataadapter();
adapter.selectcommand=cmd;
Dataset ds=new dataset();
adapter.fill(ds);
Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource("*.rdlc file datasource", ds.Tables[0]);/*for check datasource name open *.rdlc file and go to report menu->Datasources...*/

reportViewer1.LocalReport.DataSources.Clear();/*Clear datasource*/
            reportViewer1.LocalReport.DataSources.Add(reportDataSource1);/*Add Data Source*/
            reportViewer1.RefreshReport();
 
Share this answer
 

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