A
Allan Bredahl
Hi All
I have a problem with getting a DataTable to submit changes back to the
database when calling AcceptChanges.
What I do is simplyfied this :
1) I set up a SqlDataAdapter with SelectCommand, InsertCommand,
UpdateCommand and DeleteCommand pointing to each a stored procedure.
Dim ad as new SqlDataAdapter
Dim ds as new DataSet
........ I setup the adapter 1) ........
ad.Fill(ds)
Dim dt as DataTable = ds.tables("MyTable")
Dim row as DataRow = dt.NewRow
row("field1") = "New String"
row("field2") = 234{int}
row("field3") = 212.34{single}
dt.Rows.Add(row)
dt.AcceptChanges()
This adds the new row to the DataTable just fine, but nothing happens in the
database when calling AcceptChanges.
Am I missing somethig completely here, or shouldn't I be able to insert the
new row into the database using AcceptChanges ??
Do I have to call ad.Update(ds) ??
This is not so easy since in my real code the DataAdapter and the actual
DataTable is placed/used in different places.
Does anyone have a solution to this ??
Thanks in advance
Allan
I have a problem with getting a DataTable to submit changes back to the
database when calling AcceptChanges.
What I do is simplyfied this :
1) I set up a SqlDataAdapter with SelectCommand, InsertCommand,
UpdateCommand and DeleteCommand pointing to each a stored procedure.
Dim ad as new SqlDataAdapter
Dim ds as new DataSet
........ I setup the adapter 1) ........
ad.Fill(ds)
Dim dt as DataTable = ds.tables("MyTable")
Dim row as DataRow = dt.NewRow
row("field1") = "New String"
row("field2") = 234{int}
row("field3") = 212.34{single}
dt.Rows.Add(row)
dt.AcceptChanges()
This adds the new row to the DataTable just fine, but nothing happens in the
database when calling AcceptChanges.
Am I missing somethig completely here, or shouldn't I be able to insert the
new row into the database using AcceptChanges ??
Do I have to call ad.Update(ds) ??
This is not so easy since in my real code the DataAdapter and the actual
DataTable is placed/used in different places.
Does anyone have a solution to this ??
Thanks in advance
Allan