Hello,
I am using Your reporting solution, Majorsilence Reporting. I have a problem with it, so I need your help, if it's not too much trouble. Currently I'm using version 4.7, but I tried with older and newer versions, it's the same.
I've managed to create a report, and show it in the C# application, using RdlViewer component, but I can't export it to HTML, or even PDF. HTML export creates a file, but it says it has no rows, even though the result is shown correctly in a viewer component. PDF causes an exception.
I am using SQLite database, with some simple query, where I show only three columns from the same table. Here is the code I am using:
private void test()
{
RdlViewer rdlViewer = new RdlViewer();
// Set the connection:
SQLiteConnection cn = new SQLiteConnection(connection);
SQLiteCommand cmd = new SQLiteCommand();
cmd.CommandType = CommandType.Text;
// Load the report
rdlViewer.ShowWaitDialog = false;
rdlViewer.SourceFile = new Uri(path + @"\test.rdl");
string query = "SELECT Ime, Prezime, Mesto FROM Klijenti";
cmd.CommandText = query;
cmd.Connection = cn;
DataTable dt = GetTable(cmd);
rdlViewer.Report.DataSets["Data"].SetData(dt);
rdlViewer.Rebuild();
rdlViewer.SaveAs(path + @"\test.html", OutputPresentationType.HTML);
// Show the report
frmViewReport showReport = new frmViewReport();
showReport.Controls.Add(rdlViewer);
showReport.ShowDialog();
}
The GetTable method in the code is the same as in the example on this link:
https://github.com/majorsilence/My-FyiReporting/blob/master/Examples/SampleApp2-SetData/SampleApp2-SetData/Form1.cs.
As I said, it is shown correctly, but I get a warning that it is "Unable to connect to datasource 'DS1'.". Also, when I press the button Run Report, report is shown with the message that it has no rows.
Like it was written in a tutorial I read, the same SQL query is used in report and in my code, the database is the same. From Report Designer I can run the report, and it shows the correct result without any warnings. It also exports the report to HTML and PDF without problems.
I tried changing System.Data.SQLite.dll file to the one that ships with your solution, but with no luck. I put RdlViewer.dll, RdlEngine.dll and DataProviders.dll in the same folder where the application is, as well as the System.Data.SQLite.dll. I also tried changing the Data Source location in the report file from absolute to relative, but that doesn't help either.
This is the important part of the RDL file I'm using. Maybe I need to change some settings, I really don't know what seems to be the problem.
<DataSource Name="DS1">
<ConnectionProperties>
<DataProvider>SQLite</DataProvider>
<ConnectString>Data Source=G:\Projects\ReportTest\ReportTest\bin\Debug\test.sqlite</ConnectString>
</ConnectionProperties>
</DataSource>
<DataSet Name="Data">
<Query>
<DataSourceName>DS1</DataSourceName>
<CommandText>SELECT Ime, Prezime, Mesto FROM Klijenti</CommandText>
</Query>
<Fields>
<Field Name="Ime">
<DataField>Ime</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Prezime">
<DataField>Prezime</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Mesto">
<DataField>Mesto</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
I even saw code snippet about exporting (shown below) in one of the topics, but I don't know what to do next:
MemoryStreamGen ms = new MemoryStreamGen();
ProcessReport pr = new ProcessReport(rdlp.Report, ms);
pr.Run(this.ReportParams, OutputPresentationType.PDF);
I hope you can help me with this, because I just can't find the solution to it.
Thanks,
Milan