I have a winform that uses a reportviewer to show a list of records. The form load correctly shows all the records in the dataset. The form also has a ToolStrip across the top of the form that allows the user to enter four pieces of information to serach by.
The reportviewer uses an .rdlc report that is attached to the reportviewer. The datasource is also selected for the reportviewer.
The TableAdapter has two entries: the Fill,GetData() for the initial form load and the FillBy,GetDatBy(parameters) which is used when the search button in the ToolStrip is pressed.
The form load works fine but I get the message "A data source instance has not been supplied for the data source 'CardKeyDataSet_EvnLog' when I try to search.
I have Googled every which way I can think of to find an answer with no luck. I would appreciate any advise.
Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
namespace CardKey2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.EvnLogTableAdapter.Fill(this.CardKeyDataSet.EvnLog);
this.reportViewer1.RefreshReport();
}
private void fillByToolStripButton_Click(object sender, EventArgs e)
{
CardKeyDataSetTableAdapters.EvnLogTableAdapter adapter = new CardKey2.CardKeyDataSetTableAdapters.EvnLogTableAdapter();
CardKeyDataSet.EvnLogDataTable table1 = new CardKeyDataSet.EvnLogDataTable();
adapter.FillBy(table1, DateTime.Parse(BegDate.Text), DateTime.Parse(EndDate.Text), LName.Text, FName.Text);
ReportDataSource MyNewDataSource = new ReportDataSource("CardKeyDataSet.EvnLog", (DataTable)table1);
this.reportViewer1.Reset();
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.ReportEmbeddedResource = "CardKey2.CardKeyViewerList.rdlc";
this.reportViewer1.LocalReport.DataSources.Add(MyNewDataSource);
this.reportViewer1.LocalReport.Refresh();
this.reportViewer1.RefreshReport();
}
private void reportViewer1_Load(object sender, EventArgs e)
{
}
}
}