I have use following code to fill the dataset.but there is an NullExceptionRefernce error occur.
I have check the entire code,but I did not fing any error.
private void button3_Click(object sender, EventArgs e)
{
try
{
string sql = "select * from Stud";
DataSet ds = cl.FillDataset(ds, sql, "Stud");
// dataGridView1.DataSource = ds.Tables["Stud"];
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
public DataSet FillDataset(DataSet dts, string sql, string tblname)
{
OleDbCommand cmd = new OleDbCommand();
OleDbDataAdapter da = new OleDbDataAdapter(sql,cn);
//DataSet ds = new DataSet();
try
{
da.Fill(dts, tblname);
}
finally
{
cn.Close();
}
return dts;
}

Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 11, 2010, 9:42 PM EST
your problem has been solved .
Please mark my answer.
PankaJ D147 reputationPosted Mar 11, 2010, 11:26 PM EST
PankaJ D147 reputationPosted Mar 11, 2010, 11:28 PM EST