Aamir Khan

Aamir Khan

  • NA
  • 277
  • 440k

How to copy from one table to another table using dataset

Nov 12 2011 2:21 AM
hi frnds,
a query how to get data from one dataset to another dataset and update it using dataadapter.
my code is like this.

 DataSet ds = new DataSet();
                DataSet ds1 = new DataSet();


                SqlCommandBuilder Ole_Build;
                dap = new SqlDataAdapter("select * from " + tblSource + " where " + Date + " between '" + Convert.ToDateTime(FromDate).ToString("yyyy/MM/dd") + "' and '" + Convert.ToDateTime(ToDate).ToString("yyyy/MM/dd") + "'", con1);
                dap.Fill(ds, tblSource);


                SqlDataAdapter dap1 = new SqlDataAdapter("select * from " + tblDestination + " ", con);
                Ole_Build = new SqlCommandBuilder(dap1);
                dap1.AcceptChangesDuringFill = true;
                dap1.AcceptChangesDuringUpdate = true;
                dap1.Fill(ds1, tblDestination);


                DataSet dsnew = new DataSet();
                ds1 = ds.Copy();
                dap1.Update(ds1, tblDestination);


but it is not getting update


thanks & regrads,
aamir

Answers (4)