I am currently looking at moving away from crystal reports and using Microsoft Reporting in the flavor of the rdlc format at the files need to be portable and easily added to the actual application. In crystal reports and I can easily add the rpt file to a file server and have the users open the application and then point the report file, in the backend the report is opened, assigned the connection string and then passed to the viewer to generate the report.
The MS offering for this seem a bit move involved and I believe the process needs to be: upload the rdlc and xsd file to the file server and in code load the schema, populate the dataset, assign the reportdatasource, assign the report to the viewer and set the datasources and finally refresh the report.
Now my question becomes how can I populate the dataset from the query that is stored in the xsd data? My code so far is:
DataSet ds =newDataSet();
ds.ReadXmlSchema(@"C:\xx\Company_People.xsd");
Microsoft.Reporting.WinForms.ReportDataSource rds =
new Microsoft.Reporting.WinForms.ReportDataSource("CP", ds.Tables[0]);
reportViewer1.LocalReport.ReportPath =@"C:\xx\Report1.rdlc";
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.LocalReport.Refresh();
this.reportViewer1.RefreshReport();
Here is what seemingly is the relevant section from the xsd file.
Thanks
Jeremy
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="DataTable1TableAdapter" GeneratorDataComponentClassName="DataTable1TableAdapter" Name="DataTable1" UserDataComponentName="DataTable1TableAdapter">
<MainSource>
<DbSource ConnectionRef="ConnectionString (Settings)" DbObjectType="Unknown" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="false" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="false" UserGetMethodName="GetData" UserSourceName="Fill">
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="true">
<CommandText>SELECT COMPANIES.CID, COMPANIES.NAME, PEOPLE.PID, PEOPLE.FIRSTNAME, PEOPLE.LASTNAME, PEOPLE.MIDDLENAME, PEOPLE.DOB,
PEOPLE.GENDER
FROM { oj COMPANIES LEFT OUTER JOIN
PEOPLE ON COMPANIES.CID = PEOPLE.COMPANY }
WHERE (COMPANIES.CID = 9) OR
(COMPANIES.CID = 10)</CommandText>
<Parameters />
</DbCommand>
</SelectCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="CID" DataSetColumn="CID" />
<Mapping SourceColumn="NAME" DataSetColumn="NAME" />
<Mapping SourceColumn="PID" DataSetColumn="PID" />
<Mapping SourceColumn="FIRSTNAME" DataSetColumn="FIRSTNAME" />
<Mapping SourceColumn="LASTNAME" DataSetColumn="LASTNAME" />
<Mapping SourceColumn="MIDDLENAME" DataSetColumn="MIDDLENAME" />
<Mapping SourceColumn="DOB" DataSetColumn="DOB" />
<Mapping SourceColumn="GENDER" DataSetColumn="GENDER" />
</Mappings>
<Sources />
</TableAdapter>
</Tables>
<Sources />
</DataSource>