I'm a newbie to the messageboard, but I'm wondering if any of you gurus have tried to do the following before? I'm developing a custom reporting solution as part of a web application for a corporate client. One of the required features is a user-defined reporting (UDR) solution, but we cannot use ReportBuilder because their corporate firewalls prohibit ActiveX controls. Therefore, I have a wizard-style ASP.NET and C# interface that essentially allows them to go through and select the filtering parameters, fields, etc.
At the end of all that, I have generated the SQL string and I have to dynamically generate the RDLC code for this new UDR report. I have that part working and I have gone through by hand to verify that the code my rdlcGenerator is producing "appears" to be correct. (As an aside, I have opened the generated .rdlc files from within Visual Studio as well to confirm that they at least appear correct). I actually found a couple of examples on the net that helped me with the generation portion of the code. However, here's my problem:
Now that I have the new local report template that I generated, I've been unable to get it to run the actual report. I get the following error when I try to make the reportViewer display the report:
A data source instance has not been supplied for the data source 'DataSet1'.
I'll include a section of the RDLC file here to show the generic names I built into the report template:
<DataSources>
<DataSource Name="DataSource1">
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>Server=.;Database=fms_comm;User ID=usr;password=pwd;</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<DataSourceName>DataSource1</DataSourceName>
<CommandType>Text</CommandType>
<CommandText>select name as 'Name' from view_DEALER_DISPLAY</CommandText>
<Timeout>90</Timeout>
</Query>
<Fields>
<Field Name="Name">
<DataField>Name</DataField>
</Field>
</Fields>
</DataSet>
</DataSets>
And here is the c# code where I'm trying to add to add the datasource dynamically:
this.reportViewer1.ProcessingMode = ProcessingMode.Local;
this.reportViewer1.LocalReport.ReportPath = _RDLfileName;
DataTable dt;
dt = DataAccess.getDataTable(sqlText, null, false);
// the above line returns a valid dataTable that I have confirmed has records
TextReader re = File.OpenText(_RDLfileName);
ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSource1_DataSet1";
rds.Value = dt;
this.reportViewer1.LocalReport.DataSources.Add(rds );
this.reportViewer1.LocalReport.LoadReportDefinitio n(re);
this.reportViewer1.LocalReport.Refresh();
re.Close();
If any of you guys can point out the error of my ways, I will GLADY acknowledge you as Guru Extraordinaire. :)