Adding DataSource to a ReportViewer dynamically
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! :)

