"A data source instance has not been supplied for the data source" exception w/ Report Viewer Control
I'm using the webform Report Viewer control and I want to render a report locally on SQL Server Reporting Services 2005, CTP15.
After creating the report, I pointed its data source at a SQLDataSource to pull information from the AdventureWorks database. When I launch the webform, I get the following exception:
"A data source instance has not been supplied for the data source 'MyReportDataSource'"
Not good. I dig, and find out that this is a known issue with Beta 2 of Whidbey...and is already fixed in later builds. If you want to get it to work now, the short-term work around is to use an ObjectDataSource, like this:
1. In the SmartTag for the Report Viewer control, click Choose Data Source.
2. In the Choose Data Sources dialog, click inside the Data Source Instance column and choose New Data Source.
3. Choose Object in the list of data sources.
4. In the Choose your business object combo-box, you should already see the name of the Table Adapter that your report will use when it pulls data...choose it.
5. Finish off the wizard...you now should be in good shape.
Comments
Anonymous
November 10, 2005
Thank you,
You made my day, I have read many articles on this issue but no one was as clear as you
Regards,
Mehrdad.Anonymous
May 03, 2006
How about setting it an runtime?Anonymous
May 29, 2006
This works great. How do you set the connection string though for the object datasource at runtime? It works fine if using the default wizard config as you specified, but I need to change the connection string in code for when I deploy to the live server.Anonymous
June 15, 2006
that did nothing for me.Anonymous
August 01, 2006
Tried and failed. Now I can't seem to get rid of the old data source. I prevents me from running any report, telling me that it hasn't been assigned a instance, when I tried to delete it since I no longer want it.Anonymous
August 04, 2006
This is fixed now...are you guys still running a pre-RTM version?Anonymous
September 12, 2006
I am also getting this error message and haven't fix it. Could anybody let me know how to get rid off this error
RegardsAnonymous
September 27, 2006
I fixed this problem in my project and IMO it's a bug with the rdlc designer in VS 2005(I am using the released version).
I am using a Business Object called RptObject and a RptSource which has a method called Get(). The Get() method return a List<RptObject>.
The error is "A data source instance has not been supplied for the data source 'RptObject1'".
I resolved this by opening up the rdlc in Notepad and checked the XML. It turns out the Designer massed up and create two instances of the schema with name RptObject and RptObject1. My ObjectDataSource takes care of the RptObject. Therefore, I manually removed the RptObject1 and changed any references of to RptObject in the XML file.
Hope this is helpful.Anonymous
October 17, 2006
I had the same error message when instantiating a LocalReport at runtime using an ObjectDataSource. Fixed it by setting the ObjectDataSource.Value parameter.<PRE>ObjectDataSource ods = new ObjectDataSource("MyItems", "GetList");ods.ID = myODS";ods.SelectParameters.Add("userId", "100");ReportDataSource rds = new ReportDataSource("myRDS", ods.ID);rds.Value = ods; // Adding this did the trick for me.LocalReport lr = new LocalReport();lr.DataSources.Clear();lr.DataSources.Add(rds);lr.ReportPath = Server.MapPath("default.rdlc");reportOutput = lr.Render("Excel", null, out mimeType, out encoding, out extension, out streamIds, out warnings);</PRE>Hope this helps someone. :)Anonymous
October 24, 2006
Solution...The Name property in the ReportDataSource has to be set to the full dataset name. The error message itself references this name...'A data source instance has not been supplied for the data source '<name of data source>'.Use this '<name of data source>' as the ReportDataSource .Name property.Anonymous
November 14, 2006
thanks dude, saved me hours of searching.Anonymous
November 16, 2006
After choosing the data source as specified, the VS 2005 itself is closing, any clues or anything wrongAnonymous
January 11, 2007
Tamesh, I have the same problem here. Whenever I try to choose or create a data sourceinstance, the VS2005 closes. I think we found a 'exit' shortcut =P.Workaorund: do everything programmatically.Anonymous
April 02, 2007
TL's comment was the key for me. Using RTM, SP1 in fact, and hadn't realized that the name given to the ReportDataSource object in my code needed to be the same as the name given in my RDLC. Makes sense I suppose but just wasn't obvious while writing.For future reference: created RDLC based on a struct in a sub-directory/namespace (why struct? b/c it is a very simple value type). Populated a generic List<T> of instances and succesfully bound it to the report's datasource with: rpt.DataSources.Add(new ReportDataSource("MyNamespace.MyStruct", myList));Anonymous
April 02, 2007
Sorry, typed that command in wrong. Should be "MyNamespace_MyStruct" with underscore instead of period.Anonymous
April 03, 2007
When I follow steps 4 & 5 in the original posts - Visual Studio 2005 takes a dive - no event logs, nothing....Help!!!Anonymous
April 09, 2007
Great, it worked for me adding the name of datasource in the name of the report data source.Thanks!Anonymous
May 31, 2007
Resetting the report viewer control programatically is what worked for me.ReportViewer.Reset()Anonymous
July 03, 2007
Thanks, this article helped me out!Anonymous
July 23, 2007
Thanks, i needed to apply many solutions to solve my problem.Anonymous
August 19, 2007
this solution works for me....thanks to sfuquaReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = "Reports/CorrectiveActionReport.rdlc"; //this is the path of the report ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("LegalCompliance_Code_CorrectiveAction", CorrectiveAction.GetCorrectiveAction(companyId))); //static class returning a listAnonymous
October 17, 2007
Hello Am Writing the Below Coding and am get the error like A data source instance has not been supplied for the data sourceDataSet ds = new DataSet(); SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=SYM001;Initial Catalog=House;uid=sa;pwd=''"; SqlDataAdapter Sqlad = new SqlDataAdapter("Select * from Registration", con); Sqlad.Fill(ds); ObjectDataSource od = new ObjectDataSource(); ReportDataSource DataSet2_Registration = new ReportDataSource("Emp", ds.Tables[0].DefaultView); ReportViewer1.LocalReport.ReportPath = "Report1.rdlc"; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add( DataSet2_Registration); ReportViewer1.LocalReport.Refresh();Anonymous
November 20, 2007
I just went in and edited the XML directly to remove all the old artifacts and detritus that is left behind. THis is pretty appaling tool from microsoft.RobAnonymous
November 20, 2007
Hey Bob - not sure what problem you solved (and how it occured). Care to expand on things a bit?Anonymous
December 13, 2007
I came here because I had the same problem - in my case it was because I had a report definition I wanted to duplicate, so after creating the new report rdlc, I copied all the fields from the old report def into the new one. I found I had to drag the new data source columns over again (even though they were the same columns, but for a new datasource), no problem with that, but in the XML report definition I found that it retained the old datasource configuration for the copied fields. Of course in my code I didn't configure the old datasource, so I had to edit the rdlc in Notepad and remove all references to the old definition. After that, it worked.Anonymous
December 30, 2007
Thank you for the help, very useful information. My issue was resolved with the post from Tuesday, October 24, 2006 7:56 PM by TL.Anonymous
January 12, 2008
Yes!!!!!!!!!Thank you very much!!! You saved my life!Anonymous
February 13, 2008
thanks guys, saved my life too, in my case I had to open the rdlc in notepad and remove reference to the datasetname that does not exist.Anonymous
February 14, 2008
..when the DataSource Instance is only mapping say one table out of 3.Anonymous
March 15, 2008
PingBack from http://bordercrossingstatsblog.info/russell-christophers-semi-useful-bi-musings-a-data-source-instance/Anonymous
April 10, 2008
how to carry forward data from 1 report to 2 oneAnonymous
April 10, 2008
how to do paging and subtotal of first page display in top of second pageAnonymous
May 01, 2008
Make sure that the object source for the reportviewer and the datasource fro the report have the [SAME NAME] when you get the error Look for the datasource name in the error and then check1) Datasource name of the report2) ReportViewer's Object data source nameBoth these should be the sameGood luck !Anonymous
May 06, 2008
Wow!!1 Great... this information save my life too.. Very Thnaks.Anonymous
May 21, 2008
code below fixed it for me...ReportViewer1.Reset(); ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = "admin\docs\Consultants.rdlc"; ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("NTdatasets_vConsultants", ObjectDataSource1)); ReportViewer1.LocalReport.Refresh();Anonymous
June 22, 2008
Tnx everyone, the Reset does the trick - saved me (was unable to clear dataset names form the reportviewer). Though I believe the problem is with the control, because I didn't have this problem on all machines. Maybe SP1 for reportviewer fixes this.Anonymous
June 24, 2008
Many thanks for the solution, TL!! I've just been saved by your post.Anonymous
June 28, 2008
Wow when I got this error I thought I was a dead duck for sure. I did get it to work by adding the data object to the dataset for the report. I was very confused about how this instance of this object was going to work. Do I open the connection, create the object instance etc...(Can you tell I am a novice). Was doing my first web report as well so the confusion was multiplied. This all worked while 41 warning messages are displayed in Visual Studio regarding schemas and go knows what. I really hate seeing warning messages. Too much mess to clean up for now. Perhaps when I learn more I'll remove useless attributes or modify them to satisfy the assembler.Anonymous
July 29, 2008
Thanks JJones, Your solution helped me out.Anonymous
August 01, 2008
Thanks! I would have never tried this and it would have wasted a day trying to figure out the problem! Thanks again!Anonymous
August 05, 2008
Very helpful info in discerning what the error message meant.Anonymous
August 11, 2008
hey thanks !I was behind this thing since last 5 hours...thank you very muchAnonymous
September 15, 2008
Thanks to hzwang (9/27/2007) for the hint about using notepad to edit the XML.Anonymous
December 04, 2008
hzwangU save my life ! thanks a lot !!!!!!!!!!Anonymous
July 07, 2009
Man.. You are awesome.. i tried it for 3 hours and came across your post.. you really saved my day....Anonymous
July 17, 2009
I'm facing same kind of problem i'm using SSRS 2008 and VS 2008Anonymous
August 28, 2009
Thanks jjones730 !! That "rds.Value = ods" fixed my mysterious problem.Anonymous
September 01, 2009
Thanks it worked for me... : )Anonymous
October 05, 2009
Using Arun's suggestion (above) I got this to work: OrganizationDS ds = //Some method to fill the strong dataset with information//; this.reportViewer1.LocalReport.DataSources.Clear(); ReportDataSource customReportData = new ReportDataSource(); customReportData.Name = "Employee";//matches name of datasource in report customReportData.Value = ds.Employee;//the data itself reportViewer1.LocalReport.DataSources.Add(customReportData); this.reportViewer1.LocalReport.ReportPath = @".EmployeeListReport5.rdlc"; Note, Arun had a "ObjectDataSource" declaration that seems like it was unneeded.Anonymous
November 17, 2009
granadaCoder's code works perfectly to solve this issue: Here is my VB translation for those that don't do C#: Dim RDS As New ReportDataSource("FULL_DS_NAME", ObjectDataSource1) ReportViewer1.Reset() ReportViewer1.ProcessingMode = ProcessingMode.Local ReportViewer1.LocalReport.ReportPath = "report.rdlc" ReportViewer1.LocalReport.DataSources.Add(RDS)ReportViewer1.LocalReport.Refresh()Anonymous
December 19, 2009
The comment has been removedAnonymous
January 24, 2010
Thanks A lots . It Solve My problem . Solution open report as notepad remove extra data source that is in it....Anonymous
March 31, 2010
The comment has been removedAnonymous
August 25, 2010
I did what the article said and it's working on the localserver, but not after publishing to the production server.. When I publish I get the 404 error! It appears as though it has opened the report viewer because there is the beige page selector on top, but the report itself won't open and I don't know if it's the report or the datasource or what is causing the 404... HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Detailed Error Information Module IIS Web Core Notification MapRequestHandler Handler StaticFile Error Code 0x80070002Anonymous
November 19, 2010
i am just importing the rdlc file from another project to my current project bt it is not showing the output. Error showing that is "A Data source has not been supplid to your current report". plz help me.. thanks in advanceAnonymous
May 07, 2011
Thank you so much.. My report is working well now :) Thank for allah to let me open this page :)Anonymous
August 24, 2011
This article is really beneficial for me.Anonymous
August 20, 2012
Thank you so much, I got my ReportViewer finally working. I spent hours trying to find out why it wasn't working. I begin to hate Visual Studio so much.Anonymous
May 13, 2013
...and this tip is still valid today! Thank you.Anonymous
August 29, 2013
I found another way to solve this problem without having access to the SmartTag of the ReportViewer (this happened because I was using version 10 of the ReportViewer instead of a later version while also using Visual Studio.Net 2012 to do the editing). The name of the Data Set in the error message is the key. Take that name, go into source code view, find the section with the ReportViewer, then inside, find the DataSources tag, and then inside that, find the ReportDataSource tag. Inside the Name property of the ReportDataSource tag, set it to the name of the Data Source mentioned in the error message. Hopefully this will work for you as it did for me. If not, I do feel your pain.