LocalReport Error - A data source instance has not been supplied for the data source
-
Saturday, October 22, 2005 6:22 AMI have just installed VS 2005 RC.
Tried using the LocalReport control using the exact sample code provided in the help for the Render method.
I keep getting an error during the LocalReport.Render method call - InnerException = "A data source instance has not been supplied for the data source". The dataset and table supplied is valid as it works with the Reportviewer control.
Is there something I am missing or is the sample code wrong?
All Replies
-
Monday, October 24, 2005 10:51 AMI have managed to get to the bottom of this one. LocalReport is particular abount the name one passes when adding a new dataset. It must be of the form DataSet_tablename
-
Friday, October 28, 2005 7:12 PM
Go to the Report menu and select Data Sources.... This will show a list of the data sources that the report uses. -
Thursday, November 10, 2005 7:31 PMThis is a known issue with beta2 2005
do like this and your going to be okay
remember you must first create your report and then drag and drop reportviewer to you webform and set reportpath in property to the .rdlc file the use this code in code behind
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Reporting.WebForms;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ObjectDataSource objDS = new ObjectDataSource("MyDataSource2", "GetData" );
objDS.ID = "MyTable";
ReportViewer2.LocalReport.DataSources.Add(new ReportDataSource("MyDS", objDS.ID));
}
}
public class MyDataSource2
{
public DataTable GetData()
{
DataSet ds = new DataSet();
ds.DataSetName = "MyDS";
string con = "workstation id=5K57041;packet size=4096;user id=aspnet_user;data source=DGNTEST01;persist security info=True;initial catalog=PCFOnline;password=test";
SqlCommand com = new SqlCommand();
com.Connection = new SqlConnection(con);
com.Connection.Open();
SqlDataAdapter dp = new SqlDataAdapter("StoreProcName", con);
dp.Fill(ds, "MyTable");
return ds.Tables[0];
}
} -
Tuesday, May 23, 2006 5:50 PMI use two Datasources in my report, two different tables, which appear in the Datasources list as 'DataSet_Licencia' and 'DataSet_sp_ObtenerSaldo'
The thing is that my report only works when I use one of them, even though all of my textboxes refer to fields and specify of which one fo the datasource the field comes from. and I'm still getting the error: 'A data source instance has not been supplied for the data source DataSet_Licencia'
the error specifies the Dataset_Licencia, which is the second datasource that I added... -
Wednesday, May 24, 2006 7:10 PMIs there a similar solution for a windows program. I am having the same issuse, trying to export to pdf format
-
Saturday, July 15, 2006 4:56 PM
I'm still struggling with the same issue Francois Geldenhuys had before, only the solution that worked out for him still doesn't in my case.
So I'm having an intranet using a lot of RDLC files which are shown in a reportviewer. At the moment people ask me to get a PDF right away ... So this is the little code I had (and it works just fine)
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsstrafstudie_DataTable1","ObjectDataSource2"));
ReportViewer1.LocalReport.ReportPath = "rptstrafstudie.rdlc";
ObjectDataSource2.FilterExpression = "datum = '" + Request.QueryString["datum"]+ "'";And i added this
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] bytes = ReportViewer1.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamids, out warnings);
FileStream fs = new FileStream(@"c:\output.xls", FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();But I keep getting the error "A data source instance has not been supplied for the data source "dsstrafstudie_DataTable1". Alltough I DO supply a DS instance only a few rules above ? What on earth am I doing wrong?
I've been struggling with this one for weeks so any help would be very appreciated.
-
Thursday, July 27, 2006 2:03 PM
Hi,
I am experiencing the same problem. Reports render fine in the reportviewer, but as soon as I call LocalReport.Render suddenly there is no DS instance.
Has anyone discovered a solution for this?
Thanks!
-
Thursday, May 31, 2007 1:28 AM
Hi, I had the same problem... but, at least in my case, it was because the name of my datasource was wrong. Here's the line:
ReportDataSource reportDataSource = new ReportDataSource("dataSourceName", GetData());
so, the right dataSourceName was in the error message... in my case:
A Datasource instance has not been supplied for the data source 'DataSetSolicitudes_Solicitudes'
so, the right code line is:
ReportDataSource reportDataSource = new ReportDataSource("DataSetSolicitudes_Solicitudes", GetData());- Proposed As Answer by Marc Schluper Monday, July 28, 2008 8:18 PM
-
Thursday, June 21, 2007 8:28 PM
Hello,
I have the same problem you could solve it?string mimeType; string encoding; string fileNameExtension; string[] streams;Microsoft.Reporting.WebForms.
Warning[] warnings; byte[] pdfContent = this.viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);#region
crear en disco HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = "application/pdf"; HttpContext.Current.Response.AddHeader("Content-disposition", "attachment; filename=Report.pdf"); HttpContext.Current.Response.BinaryWrite(pdfContent); HttpContext.Current.Response.End();I form reportviewer and the single step for export but is not workedHelp me please!!! -
Monday, June 25, 2007 6:10 AM
Hi,
I tried using your code exactly as mentioned above but getting the same error. Is there any relation between the DataSet we create during generating the report and the dataset we have created in the code above? Should the name be same?
I also have a few queries regarding the SSRS as below
a)Is it necessary to Depoly the Report before running it.
b) In the SSRS configuration I couldnt configure the WebService Identity part. Is that causing any issues? Whenever I try to set it I get an error which says
"ReportServicesConfigUI.WMIProvider.WMIProviderException: An unknown error has occurred in the WMI Provider. Error Code 8007056B
at ReportServicesConfigUI.WMIProvider.RSReportServerAdmin.SetWebServiceIdentity(String applicationPool)"Couldnt figure out the problem.
Lastly when ever I try to preview the report it shows me the data properly, but whenI try to run the report using my ASP.NET App. it gives me the error "A data source instance has not been supplied for the data source "
Please Please Please Help Me Out Of This ISSUE....

-
Monday, June 25, 2007 9:05 AM
I am talking about the code below...
ObjectDataSource objDS = new ObjectDataSource("MyDataSource2", "GetData");objDS.ID =
"MyTable";ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(
new ReportDataSource("MyDS", objDS.ID));ReportViewer1.LocalReport.Refresh();
-
Tuesday, August 28, 2007 5:11 AM
The key is to use the Reset method of ReportViewer.
ReportViewer1.Reset();
I put it above the LocalReport datasource clear/add and it worked!
Took a few hours to find this out!
-
Tuesday, August 28, 2007 6:46 PM
If you are using the report viewer control do the following:
-
Select the ReportViewer control, right-click and select Properties
-
under the "LocalReport" click on DataSources (Collection)
-
in the new window, click on Add to add your datasource
That's it.
Ricardo D. Sanchez
GDL Technologies
- Proposed As Answer by s3rpi3nt3 Thursday, June 18, 2009 6:08 PM
-
-
Friday, October 26, 2007 8:17 AM
I experienced the same problem.
The trick that worked for me, was opening the .rdlc file in Notepad. Turns out there were 2 different datasets defined in the xml file. After removing one, everything works fine!
- Proposed As Answer by G_A_B Tuesday, July 14, 2009 4:39 PM
-
Friday, October 26, 2007 3:19 PM
I've had issues similar to this before. Under some circumstances the Report Designer appears to leave Dataset definiitions in the RDLC even once they are removed (via the Designed interface.)
I don't understand why exactly and I'm not about to try horking projects in order to try to force a repro.
-
Saturday, November 24, 2007 6:38 AMHi,
I also faced this problem and it troubled me alot, but came to know a simpler way to resolve it. Open .rdlc in VS2005, in the menu bar select Report menu, select Data Sources from the submenu, there you'll find a list of data sources, select one and
click remove to delete it. You don't need to find them in .rdlc files opened in notepad. -
Friday, January 18, 2008 10:26 AM
Please check the Data source name, it is case sensitive -
Friday, December 05, 2008 1:41 AMYou want to know what worked for me? I had a button on the .aspx page to run the Render code and it was positioned between the two datasources for the reportviewer control on the page. The error I got was complaining about the 2nd datasource. So on a whim I tried moving the button BELOW the 2nd datasource, and lo and behold IT WORKED!!
-
Friday, December 05, 2008 1:55 AMYeah scratch that last reply, it works now no matter how the button is placed.
-
Tuesday, July 14, 2009 4:45 PMI had this problem a lot of times, and the solution was always this one. Don't waste time checking other things, First of all, you must check the codebehind in the .rdlc just like jbv said!
-
Friday, August 28, 2009 7:49 PMOK. I have read the postings and tried to get the code to work, but still not able to.
Here is the situation.
I have built the rdlc using a dummy dataset "IBM_Dataset" and the dummy table "Invoices_x".
I attached the rdlc to a reportviewer. In the viewer Load event, I change the datasource to an in-memory dataset "Commissions" and also change the datamember to the table "INVOICES".
The viewer displays beautifully.
But in some instances I want to just print the report (not display the viewer).
So, I copy code from the forum. I am not really sure where the code goes. but i put it in the button_click event.
It seems like it is still trying to use the dummy dataset and table. I am unsure of how to tell it I want to use my in-memory dataset.
I am getting the error posted in this thread. could someone please look at the code and tell me what I have done wrong.
Imports System
Imports System.IO
Imports System.Data
Imports System.Text
Imports System.Drawing.Imaging
Imports System.Drawing.Printing
Imports System.Collections.Generic
Imports Microsoft.Reporting.WinForms
Public Class DirectPrinting
Implements IDisposable
Public Sub Run()
Dim report As New LocalReport()
report.ReportPath = "rpt_Terr_Payables.rdlc"
report.DataSources.Add(New ReportDataSource("Commissions", LoadSalesData()))
'iNet.frm_commissionspayables.ReportViewer1.LocalReport.DataSources.Clear()
'iNet.frm_commissionspayables.Invoices_xBindingSource.DataSource = iNet.Commissions
'iNet.frm_commissionspayables.Invoices_xBindingSource.DataMember = "INVOICES"
iNet.frm_commissionspayables.ReportViewer1.LocalReport.Refresh()
Export(report)
m_currentPageIndex = 0
Print()
End Sub
Private m_currentPageIndex As Integer
Private m_streams As IList(Of Stream)
Private Function LoadSalesData() As DataTable
Dim dataSet As New DataSet("iNet.Commissions")
Return dataSet.Tables("INVOICES")
End Function
Private Sub Export(ByVal report As LocalReport)
Dim deviceInfo As String = _
"<DeviceInfo>" + _
" <OutputFormat>EMF</OutputFormat>" + _
" <PageWidth>8.5in</PageWidth>" + _
" <PageHeight>11in</PageHeight>" + _
" <MarginTop>0.25in</MarginTop>" + _
" <MarginLeft>0.25in</MarginLeft>" + _
" <MarginRight>0.25in</MarginRight>" + _
" <MarginBottom>0.25in</MarginBottom>" + _
"</DeviceInfo>"
Dim warnings() As Warning = Nothing
m_streams = New List(Of Stream)
report.Render("Image", deviceInfo, AddressOf CreateStream, warnings)
Dim stream As Stream
For Each stream In m_streams
stream.Position = 0
Next stream
End Sub
'Private Function CreateStream(ByVal name As String, ByVal fileNameExtension As String, ByVal encoding As Encoding, ByVal mimeType As String, ByVal willSeek As Boolean, ByVal oper As Microsoft.ReportingServices.Interfaces.StreamOper) As Stream
Private Function CreateStream(ByVal name As String, ByVal fileNameExtension As String, ByVal encoding As Encoding, ByVal mimeType As String, ByVal willSeek As Boolean) As Stream
Dim rc As Stream = New FileStream(name + "." + fileNameExtension, FileMode.Create)
m_streams.Add(rc)
Return rc
End Function
Private Sub PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
Dim pageImage As New Metafile(m_streams(m_currentPageIndex))
ev.Graphics.DrawImage(pageImage, 0, 0)
m_currentPageIndex += 1
ev.HasMorePages = m_currentPageIndex < m_streams.Count
End Sub
Private Sub Print()
Const printerName As String = "Microsoft Office Document Image Writer"
If m_streams Is Nothing Or m_streams.Count = 0 Then
Return
End If
Dim printDoc As New PrintDocument()
printDoc.PrinterSettings.PrinterName = printerName
If Not printDoc.PrinterSettings.IsValid Then
Dim msg As String = [String].Format("Can't find printer ""{0}"".", printerName)
Console.WriteLine(msg)
Return
End If
AddHandler printDoc.PrintPage, AddressOf PrintPage
printDoc.Print()
End Sub
Duane Sanders -
Thursday, September 24, 2009 9:01 AM
I had the same problem as everyone else but this solution didn't work. However, it may have been due to the fact that I was trying to build & export the report in the Page_Load event of the aspx page. Therefore, all I did was to leave the DataSources collection property of the LocalReport object unpopulated but instead set it in code thus:If you are using the report viewer control do the following:
-
Select the ReportViewer control, right-click and select Properties
-
under the "LocalReport" click on DataSources (Collection)
-
in the new window, click on Add to add your datasource
That's it.
Ricardo D. Sanchez
GDL Technologies
MyReportViewer.LocalReport.DataSources.Add(new ReportDataSource("MySSRSReportDataetName", MySqlDataSource));
Worked a treat. :-) -
-
Thursday, August 26, 2010 4:02 PM
Be sure that the datatables and datasets you are sending to the report are actually named. ie.
reportDATASET.DataSetName =
"reportDATASET"
dataDT.TableName ="dataDT"
this one has got me a couple times.
hope it helps
gc
-
Monday, January 10, 2011 3:30 AM
Go into the XML and look for where it says "DataSet1".
Change it to the correct DataSet.
I think this is a conversion issue in "upgrading".
-
Thursday, April 14, 2011 7:57 AM
I experienced the same problem too.
i tried to use the dataset_tablename and did not work, but when i opened the report using notepad i found that it was DataSet1.
this because sometimes when creating the report using the wizard, you forget to rename the default dataset name, so it still remains DataSet1, and you can make sure of this when opening the rdlc report file using the notepad.
This worked with me.
Maher Abu Zer Software Development Officer -
Monday, May 09, 2011 1:17 PM
I was facing the same problem i found the solution by.
i go to designer view of report Viewer
Manually add report data source
Microsoft.Reporting.WinForms.ReportDataSource reportDataSource3 = new Microsoft.Reporting.WinForms.ReportDataSource();
this.myBindingSource = new System.Windows.Forms.BindingSource(this.components);
And then define the value of my data binding sourcereportDataSource3.Name = "StockDbDataSet_myTableName"; reportDataSource3.Value = this.myBindingSource ;- Proposed As Answer by Zain_Ali Tuesday, May 24, 2011 11:52 AM
-
Friday, May 27, 2011 7:16 AM
Thanks guyz!!!
Your suggestions give me a good hint and the issue fixed instantly.
The main thing I noticed here is make sure the Typed Dataset name u assign is correct (it is case sensitive).
Sample code:
//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("DataSet1",
thisDataSet.Tables[0]);//ReportViewer1.Reset();
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();
- Proposed As Answer by xpertprogrammer Friday, May 27, 2011 7:17 AM
-
Thursday, January 05, 2012 11:41 AMThat is the correct solution!! The error page states the name of the DataSource so you specify the name in the ReportDataSource and it works fine.
-
Friday, June 15, 2012 1:09 AM
This is what worked for me, see here: http://msdn.microsoft.com/en-us/library/ms252085(v=vs.90), Rebinding DataSources to the ReportViewer control:
-
Open the form or Web page that contains the ReportViewer control. -
In the ReportViewer Tasks smart tags panel, click Rebind Data Sources. You can inspect the code behind the form or page to confirm the changes.
-
-
Friday, July 27, 2012 5:29 PMThanks! You saved my day.
-
Sunday, December 02, 2012 5:31 PMit helped me today thanks
-
Thursday, May 16, 2013 8:31 PM@ijoab - You ROCK!

