469,270 Members | 1,117 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Reportviewer A data source instance has not been supplied for subreport

I have created a report and subreport in VB/ASP.NET. The report works fine but the subreport will not display. The subreport, when displayed as a standalone report, works fine. But when viewed as a subreport I get the error that the datasource for the subreport is missing.
I set a breakpoint in the sub that should set the subreport's datasource and the breakpoint is never hit. I have added a handler like shown in many examples. Why is the subreportprocessing event never firing? I have spent days trying to figure this out but most examples refer to the WinForms.ReportViewer and
none to the WebForms.ReportViewer. I have never found a complete webforms example using a subreport.
Any help would be greatly appreciated,
Kim
Jun 7 '07 #1
3 35072
adunn
1
This may just be a configuration issue. Check your subreport's Data Sources. The report designer seems greedy and grabs all available datasources. Delete the ones you don't need, and you should be good to go.
Jun 11 '07 #2
Hi Try this , will work for you...


public partial class _Default : System.Web.UI.Page
{
int ordno = 134085104;
string thisConnectionString = "server=.;initial catalog=vivotech;uid=sa;pwd=sql";
SqlConnection thisConnection = new SqlConnection(thisConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
ReportViewer1.Visible = true;

thisConnection.Open();
{
SqlCommand cm = new SqlCommand("Vivo_Report", thisConnection);
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.Add("OrderNumber", SqlDbType.Int).Value = ordno;
SqlDataAdapter da = new SqlDataAdapter(cm);
System.Data.DataSet thisDataSet = new System.Data.DataSet();
da.Fill(thisDataSet, "Vivo_Report");
ReportDataSource datasource = new ReportDataSource("DataSet1_Vivo_Report", thisDataSet.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasour ce);
this.ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessin gEventHandler);
ReportViewer1.LocalReport.Refresh();
}
thisConnection.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{

}

public void SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
{
SqlCommand cm = new SqlCommand("Vivo_Report", thisConnection);
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.Add("OrderNumber", SqlDbType.Int).Value = ordno;
SqlDataAdapter da = new SqlDataAdapter(cm);
System.Data.DataSet thisDataSet = new System.Data.DataSet();
da.Fill(thisDataSet, "Vivo_Report");
e.DataSources.Add(new ReportDataSource("DataSet1_VivoReport", thisDataSet.Tables[0]));
thisConnection.Close();
}
}
May 9 '09 #3
Iam using the below code, everything is working fine am able to get the main report but the problem is report viewer doesn't show the subreport throws a error message: subreport could not be shown
Pls help me.

public partial class _Default : System.Web.UI.Page
{
int ordno = 134085104;
string thisConnectionString = "server=.;initial catalog=vivotech;uid=sa;pwd=sql";
SqlConnection thisConnection = new SqlConnection(thisConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
ReportViewer1.Visible = true;

thisConnection.Open();
{
SqlCommand cm = new SqlCommand("Vivo_Report", thisConnection);
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.Add("OrderNumber", SqlDbType.Int).Value = ordno;
SqlDataAdapter da = new SqlDataAdapter(cm);
System.Data.DataSet thisDataSet = new System.Data.DataSet();
da.Fill(thisDataSet, "Vivo_Report");
ReportDataSource datasource = new ReportDataSource("DataSet1_Vivo_Report", thisDataSet.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasour ce);
this.ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessin gEventHandler);
ReportViewer1.LocalReport.Refresh();
}
thisConnection.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{

}

public void SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
{
SqlCommand cm = new SqlCommand("Vivo_Report", thisConnection);
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.Add("OrderNumber", SqlDbType.Int).Value = ordno;
SqlDataAdapter da = new SqlDataAdapter(cm);
System.Data.DataSet thisDataSet = new System.Data.DataSet();
da.Fill(thisDataSet, "Vivo_Report");
e.DataSources.Add(new ReportDataSource("DataSet1_VivoReport", thisDataSet.Tables[0]));
thisConnection.Close();
}
}
May 9 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Steven | last post: by
2 posts views Thread by James Neumann | last post: by
3 posts views Thread by Xpeppe | last post: by
3 posts views Thread by Fresno Bob | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.