PankaJ D

PankaJ D

  • NA
  • 154
  • 0

Dataset

Mar 12 2010 1:36 AM

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;

       }

 


Attachment: BestTest.rar

Answers (3)