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="DataSourc e1">
<ConnectionProp erties>
<DataProvider>S QL</DataProvider>
<ConnectString> Server=.;Databa se=fms_comm;Use r ID=usr;password =pwd;</ConnectString>
<IntegratedSecu rity>true</IntegratedSecur ity>
</ConnectionPrope rties>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1" >
<Query>
<DataSourceName >DataSource1</DataSourceName>
<CommandType>Te xt</CommandType>
<CommandText>se lect name as 'Name' from view_DEALER_DIS PLAY</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.reportView er1.ProcessingM ode = ProcessingMode. Local;
this.reportView er1.LocalReport .ReportPath = _RDLfileName;
DataTable dt;
dt = DataAccess.getD ataTable(sqlTex t, null, false);
// the above line returns a valid dataTable that I have confirmed has records
TextReader re = File.OpenText(_ RDLfileName);
ReportDataSourc e rds = new ReportDataSourc e();
rds.Name = "DataSource1_Da taSet1";
rds.Value = dt;
this.reportView er1.LocalReport .DataSources.Ad d(rds);
this.reportView er1.LocalReport .LoadReportDefi nition(re);
this.reportView er1.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. :)
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="DataSourc e1">
<ConnectionProp erties>
<DataProvider>S QL</DataProvider>
<ConnectString> Server=.;Databa se=fms_comm;Use r ID=usr;password =pwd;</ConnectString>
<IntegratedSecu rity>true</IntegratedSecur ity>
</ConnectionPrope rties>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1" >
<Query>
<DataSourceName >DataSource1</DataSourceName>
<CommandType>Te xt</CommandType>
<CommandText>se lect name as 'Name' from view_DEALER_DIS PLAY</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.reportView er1.ProcessingM ode = ProcessingMode. Local;
this.reportView er1.LocalReport .ReportPath = _RDLfileName;
DataTable dt;
dt = DataAccess.getD ataTable(sqlTex t, null, false);
// the above line returns a valid dataTable that I have confirmed has records
TextReader re = File.OpenText(_ RDLfileName);
ReportDataSourc e rds = new ReportDataSourc e();
rds.Name = "DataSource1_Da taSet1";
rds.Value = dt;
this.reportView er1.LocalReport .DataSources.Ad d(rds);
this.reportView er1.LocalReport .LoadReportDefi nition(re);
this.reportView er1.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. :)
Comment