Adding DataSource to a ReportViewer dynamically

I have a ReportViewer in which I dynamically loaded a RDLC file (Local Processing mode). I need to provide the data to the ReportViewer so I try to add a new ReportDataSource object to the ReportViewer.LocalReport.DataSources.
All I get is an ArgumentException with the message "Value does not fall within the expected range"
sqlConnection1.ConnectionString = ConnectionString(connectionRef);
sqlCommand1.CommandType = CommandType.StoredProcedure;
sqlCommand1.Connection = sqlConnection1;
sqlCommand1.CommandText = storedProcedureName;
sqlDataAdapter1.SelectCommand = sqlCommand1;
sqlDataAdapter1.TableMappings.Clear();
for (int i = 0; i < dsData.Tables.Count; i++)
{
sqlDataAdapter1.TableMappings.Add("Table" + (i == 0 ? "" : i.ToString()), dsData.Tables[ i ].TableName);
}
sqlDataAdapter1.Fill(dsData);

reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.LocalReport.ReportPath = @"C:\Temp\ReportEngine\ReportEngine\ReportDefinition.rdlc";
reportViewer1.LocalReport.DataSources.Clear();
ReadOnlyCollection<string> dataSourcesNames = (ReadOnlyCollection<string>)reportViewer1.LocalReport.GetDataSourceNames();

ReportDataSource rds = new ReportDataSource();
rds.Name = dataSourcesNames[0];
rds.Value = dsData; // < - - - - - - - - - - - - -HERE STRIKES THE EXCEPTION
reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.RefreshReport();

The exception is thrown at the line where I assign the typed DataSet to the ReportDataSource's Value property.
What am I doing wrong here?
TIA! :)

[1661 byte] By [AndreiR23] at [2008-1-7]
# 1
It seems that I have to specify a DataTable as the "Value" property of the ReportDataSource not a DataSet which is not allowed.
However when I am trying to add a DataSource to the Report Definition as a DataTable (typed DataTable or untyped) I get : "The service 'Microsoft.VisualStudio.Shell.Interop.IVsRunningDocumentTable' must be installed for this operation to succeed. Ensure that this service is available"
This puzzles me as I've installed MS VS2005 quite complete
AndreiR23 at 2007-10-2 > top of Msdn Tech,Visual Studio,Visual Studio Report Controls...
# 2

I was getting a simillar error. But instead of binding my report to a DataSet I was binding it to a strongly typed business object. It turns out that the error was occuring as I was binding it to a single instance of my business object. To fix this error I created a Generic List of my strongly typed object, added my single instance to this collection and added this list to the report datasources.....it worked Smile

AmitReddy at 2007-10-2 > top of Msdn Tech,Visual Studio,Visual Studio Report Controls...
# 3
I had the same problem & I solved it by assigning a DataTable to 'Value' property, instead of DataSet.

Code Snippet

DataSet myDataSet = myDb.ExecuteDataSet(dbCmd); //using DAAB

myReportViewer.LocalReport.DataSources.Clear();
myReportViewer.LocalReport.DataSources.Add(new ReportDataSource("ReportDataSource", myDataSet.Tables[0]));


Hope this helps!
Haresh at 2007-10-2 > top of Msdn Tech,Visual Studio,Visual Studio Report Controls...

Visual Studio

Site Classified