473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 35589
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

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

Similar topics

5
by: grondaia | last post by:
Here's my situation: I have an ODBC DSN setup for Timberline Data (An accounting package that uses pervasive.sql) on my sql box. I set up a linked server using the supplied timberline odbc...
0
by: Steven | last post by:
I have a windows 2000 server running V8 fix pack 4a with the DB2 Instance. I wanted to move the active database off of the db2 instance away from the TOOLSDB so I created a new instance INST2. I...
2
by: James Neumann | last post by:
Environment: Access 2k, win2k Business Problem: I have to display returns on investments made over a period of years, and show the amount of return earned on each investment by year. For...
3
by: Xpeppe | last post by:
Hy, i read the article in msdn2 Using a Database Data Source with the ReportViewer Windows Forms Control in Local Processing Mode But i don want to use the designer assosation to the report,...
7
by: John J. Hughes II | last post by:
I have a DataGridView with a TextBoxColumn. I setting the data source to a List<stringvalue in a static class. The list is filled from a background thread. So far all is fine and it works...
1
by: GSReddy | last post by:
Hi I am trying to build bar chart in asp.net using ReportViewer data control with some sample data write here. string name = new string{"Trans", "DAS", "Lap H/w", "Lap S/w", "People"}; int val =...
0
by: NaveenDuggal | last post by:
Hi All I have designed a rdlc file, using Business Object and table control, and added it on Report Viewer control. I am facing the excepiton Exception descritption: A data source instance has...
3
by: Fresno Bob | last post by:
When you bind to the object data source you can bind to the underlying dataset that is returned by the select statement but can you bind to the properties of the object? MSDN says the...
1
by: Coderer | last post by:
I have a project that I've been working on for a while, where several forms use DataGridViews to represent database information. The forms are .NET 2.0, in Studio 2005. For the past couple of...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.