By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,344 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,344 IT Pros & Developers. It's quick & easy.

datatable update error (does update instead of insert)

P: n/a
I have the following datatables which are related:

Transaction
TransactionId-Sequence
Orders
OrderDetails

when I process a
daTransaction.update(dtTransaction)
daTransactionIdSequence.update(dtTransactionIdSequ ence)
daOrders.update(dtOrders)
daOrderDetails.update(dtOrderDetails)

each table is linked with foreign key relationships in the .xsd file and I
can easily get parentrow information. When I populate the datatables and
run the update, each one works by executing an insert and popluates the next
datatable with the new transaction id which sql generated from an identity
field and returnd it via @@identity to the drTransaction datatable. But
when I try to update drOrderDetails last, it thinks it is doing an update
and not an insert and fails because it is not in the database yet.

Any clues as to what is happening here? The insert statement is simple and
to the point in the dataadapter and so is the update statement. It is just
using the wrong statement.

Thanks,

Scott Emick
Sofware Engineer
Fox International

--
Scott Emick
Web Programmer
Fox International
Remove the ham from mail address if it's not spam
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Check the Rowstate of each row. New Rows shoudl be 'Added' updates ones
should be Changed. I'd also recommend using Sql Profiler to see what's
being sent to the database - this is the ultimate arbiter of what's being
done so it's probably your best bet.
"Scott Emick" <se****@ham.fox-international.com> wrote in message
news:uU**************@TK2MSFTNGP15.phx.gbl...
I have the following datatables which are related:

Transaction
TransactionId-Sequence
Orders
OrderDetails

when I process a
daTransaction.update(dtTransaction)
daTransactionIdSequence.update(dtTransactionIdSequ ence)
daOrders.update(dtOrders)
daOrderDetails.update(dtOrderDetails)

each table is linked with foreign key relationships in the .xsd file and I
can easily get parentrow information. When I populate the datatables and
run the update, each one works by executing an insert and popluates the
next datatable with the new transaction id which sql generated from an
identity field and returnd it via @@identity to the drTransaction
datatable. But when I try to update drOrderDetails last, it thinks it is
doing an update and not an insert and fails because it is not in the
database yet.

Any clues as to what is happening here? The insert statement is simple
and to the point in the dataadapter and so is the update statement. It is
just using the wrong statement.

Thanks,

Scott Emick
Sofware Engineer
Fox International

--
Scott Emick
Web Programmer
Fox International
Remove the ham from mail address if it's not spam

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.