I have created a project in WPF connecting to MySQL for data.
In that I add a report viewer with the use of
WindowsFormsHost
, and I add the rdlc report int this. I include a table and set the dataset columns into that.
In XAML
<window x:class="User.FeedbackReport" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewer="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms"
Title="FeedbackReport" Height="700" Width="1000" Loaded="Window_Loaded" xmlns:my="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer" WindowStartupLocation="CenterScreen">
<windowsformshost name="host" margin="0,34,0,0">
<viewer:reportviewer margin="0,34,0,0" x:name="reportViewer1" xmlns:viewer="#unknown" />
</windowsformshost>
</window>
My code-behind for this is
private void Window_Loaded(object sender, RoutedEventArgs e)
{
mcs_kioskDataSet kds = new mcs_kioskDataSet();
ReportDataSource rds = new ReportDataSource();
rds.Value = kds.Tables[0];
reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.LocalReport.ReportPath = @"D:\Jagadeeswaran\Project\User\User\Report1.rdlc";
reportViewer1.RefreshReport();
host.Child = reportViewer1;
}
When I click a button, the Report viewer shows the following error message:
A data Source instance has not been supplied for the data source DataSet1
I have Googled for a solution to this problem, which brought up
this[
^] answer:
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("dataset1", myDataSource));
I tried that too, but I can't get the result.
I am already using Winform to do this. In that I solve this problem by clicking the Report Viewer smart tag, and set the datasource. But in WPF I can't get this smart tag. Does anybody have any ideas on how I can fix this?