Hi,
I am not too sure if this works, but here's what i feel is the problem.
DataAdapter.Update works based on the RowState of the DataRow.
So a DataRowState.Added will lead to the record being inserted into the
database, while a DataRowState.Modified will lead to the record being updated
in the database.
Now the RowState property of the DataRow within a DataTable is read-only.
But the only way to modify it is to first add the row in the DataTable in you
class and then modify its values.
ie
(from MSDN)
private void DemonstrateRowState() {
//Run a function to create a DataTable with one column.
DataTable myTable = MakeTable();
DataRow myRow;
// Create a new DataRow.
myRow = myTable.NewRow();
// Detached row.
Console.WriteLine("New Row " + myRow.RowState);
myTable.Rows.Add(myRow);
// New row.
Console.WriteLine("AddRow " + myRow.RowState);
myRow["FirstName"] = "Scott";
// Modified row.
// After Modification the Row should now Update to the Database
Console.WriteLine("Modified " + myRow.RowState);
}
private DataTable MakeTable(){
// Make a simple table with one column.
DataTable dt = new DataTable("myTable");
DataColumn dcFirstName = new DataColumn("FirstName",
Type.GetType("System.String"));
dt.Columns.Add(dcFirstName);
return dt;
}
Regards,
Saurabh Nandu
[
www.AksTech.com ]
[
www.MasterCSharp.com ]
[quoted text, click to view] "Robin" wrote:
> In a .Net solution that has a DAL, Class and Business logic.
> When recreating a dataset from the class the records are inserted into the
> database from the dataset instead of updating. This is using the dataset
> merge command.
>
> Is there any settings that should be used to ensure that the data is
> updating instead of inserted?
>
>