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 ChoudharyPosted Mar 12, 2010, 2:42 AM
your problem has been solved .
Please mark my answer.
PankaJ DPosted Mar 12, 2010, 4:28 AM
PankaJ DPosted Mar 12, 2010, 4:26 AM