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
Loading
Aamir KhanPosted Nov 12, 2011, 6:34 AM
Manoj SevdaPosted Nov 12, 2011, 5:15 AM
Aamir KhanPosted Nov 12, 2011, 4:33 AM
Manoj SevdaPosted Nov 12, 2011, 4:11 AM
Try this ...
// Check for changes with the HasChanges method first.
if(!myDataSet.HasChanges(DataRowState.Modified))
return;
// Create temporary DataSet
DataSet xDataSet;
// GetChanges for modified rows only.
xDataSet = myDataSet.GetChanges(DataRowState.Modified);
// Check the DataSet for errors.
if(xDataSet.HasErrors)
{
// Insert code to resolve errors.
}
// After fixing errors, update the data source with the DataAdapter
// used to create the DataSet.
myOleDbDataAdapter.Update(xDataSet);