Please double check your datasource firstly. maybe you get the null value to the reportviewer control.
Here is an example, please double check that.
public partial class ReportViewerLocalMode : System.Web.UI.Page
{
public string thisConnectionString =
ConfigurationManager.ConnectionStrings[
"NorthwindConnectionString"].ConnectionString;
/*I used the following statement to show if you have multiple
input parameters, declare the parameter with the number
of parameters in your application, ex. New SqlParameter[4]; */
public SqlParameter[] SearchValue = new SqlParameter[1];
protected void RunReportButton_Click(object sender, EventArgs e)
{
//ReportViewer1.Visible is set to false in design mode
ReportViewer1.Visible = true;
SqlConnection thisConnection = new SqlConnection(thisConnectionString);
System.Data.DataSet thisDataSet = new System.Data.DataSet();
SearchValue[0] = new SqlParameter("@CategoryName",
DropDownList1.SelectedValue);
/* Put the stored procedure result into a dataset */
thisDataSet = SqlHelper.ExecuteDataset(thisConnection,
"ShowProductByCategory", SearchValue);
/*or thisDataSet = SqlHelper.ExecuteDataset(thisConnection,
"ShowProductByCategory", dropdownlist1.selectedvalue);
if you only have 1 input parameter */
/* Associate thisDataSet (now loaded with the stored
procedure result) with the ReportViewer datasource */
ReportDataSource datasource = new
ReportDataSource("DataSetProducts_ShowProductByCategory",
thisDataSet.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
if (thisDataSet.Tables[0].Rows.Count == 0)
{
lblMessage.Text = "Sorry, no products under this category!";
}
ReportViewer1.LocalReport.Refresh();
}
}
selva.krish
Member
2 Points
5 Posts
A data source instance has not been supplied for the data source 'DataSet1'
May 14, 2010 12:12 PM|LINK
Dear all..
I am getting the following error while i bind the dataset dynamically in reportviewer(Asp .net 4.0) . I have binded the dataset using stroedprocedure.
Error:A data source instance has not been supplied for the data source 'DataSet1'.
Thank you,
Selva kumar.
ignatandrei
All-Star
135174 Points
21682 Posts
Moderator
MVP
Re: A data source instance has not been supplied for the data source 'DataSet1'
May 14, 2010 01:08 PM|LINK
do you have something like :
<localreport>.DataSources.Add("DataSet1", the dataset)?
or what is your code?
Pathiya007
Member
268 Points
264 Posts
Re: A data source instance has not been supplied for the data source 'DataSet1'
May 14, 2010 01:45 PM|LINK
<DataSources >
<rsweb:ReportDataSource DataSourceId ="datasobject" Name ="nameof.xsdfilewhichhasdataadpter_giveyourstoredprocedurename" />
</DataSources>
post your code that would be easy to identify error. in the name property give name of xsd file then underscore name of stored procedure.
then after reportviewer closing tab
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="datasobject" runat="server" SelectMethod="GetData"
TypeName="xxxxxxxxxxxxxxxTableAdapters.kkkkkkkkkkkkkkkkkkkTableAdapter"></asp:ObjectDataSource>
same as above replace xxxxx and kkkkkkk
Thanks,
Pathiya
(Please mark as an answer if yes)
Bober Song -...
All-Star
34686 Points
2167 Posts
Re: A data source instance has not been supplied for the data source 'DataSet1'
May 18, 2010 07:07 AM|LINK
Hi selva.krish ,
Please double check your datasource firstly. maybe you get the null value to the reportviewer control.
Here is an example, please double check that.
public partial class ReportViewerLocalMode : System.Web.UI.Page { public string thisConnectionString = ConfigurationManager.ConnectionStrings[ "NorthwindConnectionString"].ConnectionString; /*I used the following statement to show if you have multiple input parameters, declare the parameter with the number of parameters in your application, ex. New SqlParameter[4]; */ public SqlParameter[] SearchValue = new SqlParameter[1]; protected void RunReportButton_Click(object sender, EventArgs e) { //ReportViewer1.Visible is set to false in design mode ReportViewer1.Visible = true; SqlConnection thisConnection = new SqlConnection(thisConnectionString); System.Data.DataSet thisDataSet = new System.Data.DataSet(); SearchValue[0] = new SqlParameter("@CategoryName", DropDownList1.SelectedValue); /* Put the stored procedure result into a dataset */ thisDataSet = SqlHelper.ExecuteDataset(thisConnection, "ShowProductByCategory", SearchValue); /*or thisDataSet = SqlHelper.ExecuteDataset(thisConnection, "ShowProductByCategory", dropdownlist1.selectedvalue); if you only have 1 input parameter */ /* Associate thisDataSet (now loaded with the stored procedure result) with the ReportViewer datasource */ ReportDataSource datasource = new ReportDataSource("DataSetProducts_ShowProductByCategory", thisDataSet.Tables[0]); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); if (thisDataSet.Tables[0].Rows.Count == 0) { lblMessage.Text = "Sorry, no products under this category!"; } ReportViewer1.LocalReport.Refresh(); } }http://www.codeproject.com/KB/webforms/ReportViewer.aspx
http://blogs.msdn.com/magreer/archive/2008/10/16/setting-the-datasource-for-a-report-at-runtime.aspx
http://msdn.microsoft.com/en-us/library/ms252094(VS.80).aspx
I hope it is helpful to you.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework