Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Updating a Detached DataRow

356 views
Skip to first unread message

Bob Day

unread,
Jul 14, 2004, 12:57:27 PM7/14/04
to
Using VS 2003, VB.net, MSDE...

I am trying to 1) create and fill a detached datarow, 2) modify some of its
columns and 3) Update those modifications back to the datasource table. It
is step 3 that is failing, no errors, just 0 rows updated. I think the
problem lies in the fact that the datarow has a row state of "detached" (but
I am not sure how change that, since AddNewRow will create a new row, not
modify an existing one).
Step 1
Dim myDataRow as DataRow = Nothing
myDataRow = myDataAdapeter.Fill()
' myDataRow fills as expected
' I realize in Step 1 I could fill a dataset, set the DataRow = a row in
the dataset, thus making the RowState "Modified" , which then Updates
correctly in Step 3 (this may be the only way to do it).

Step 2
myDataRow.Column = New_Value
' myDataRow has New_Value as expected

Step 3
dim myDataRowArray() as DataRow = {myDataRow}
' myDataRowArray shows a length of 1, and the New_Value is in that 1 item as
expected

Rows_Updated = myDataAdapter.Update(myDataRowArray)
' Rows_Updated = 0, no error, not sure why.

So, why am I not getting anyting updated? I think the

Thanks!
Bob Da


Uri Dor

unread,
Jul 15, 2004, 5:32:42 AM7/15/04
to
what about Table.Rows.Add(row)?

Bob Day

unread,
Jul 15, 2004, 2:07:19 PM7/15/04
to
Table.Rows.Add(row) will add it as a seperate additional row, not update the
changes to the existing row in the DataSource. If you have a constraint
(such as a foreign key) that must be unique, then of course, adding this row
will also throw an execption.

Any other thoughts?

Thanks!
Bob Day

"Uri Dor" <tab...@newsgroups.nospam> wrote in message
news:eNIMwYka...@TK2MSFTNGP11.phx.gbl...

Martin

unread,
Sep 3, 2009, 10:31:39 AM9/3/09
to
you will find here that importing a row with rowstate detached, it is ignored without any exception.

And change the rowstate to Added or Modified is not allowed. don't know how to change this.

From http://www.developmentnow.com/g/7_2004_7_0_0_132323/Updating-a-Detached-DataRow.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com/g/

Martin

unread,
Sep 3, 2009, 10:32:21 AM9/3/09
to
0 new messages