"The ConnectionString property has not been initialized." Error for DataAdapter.Fill() in C#

  • Thread starter Thread starter Student Developer Jas
  • Start date Start date
S

Student Developer Jas

Guest
I'm trying to add a Crystal Report Viewer in Windows form but it shows error for DataAdapter.Fill()

This is my code:

namespace Trying
{
public partial class Form2 : Form
{
OleDbConnection cn = new OleDbConnection();
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
ReportDocument Cryrpt = new ReportDocument();
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter("Select * from Table1 Where [Name] ='" + textBox1.Text + "'",cn);

da.Fill(ds,"Table1");
Cryrpt.Load(@"E:\\New Volume (E)\\sem6 project\\Trying\\Trying\\Reports\\CrystalReport1.rpt");
Cryrpt.SetDataSource(ds);
crystalReportViewer1.ReportSource = Cryrpt;
ds.Dispose();

}

}


}

Continue reading...
 
Back
Top