datatable update error (does update instead of insert)

  • Thread starter Thread starter Scott Emick
  • Start date Start date
S

Scott Emick

I have the following datatables which are related:

Transaction
TransactionId-Sequence
Orders
OrderDetails

when I process a
daTransaction.update(dtTransaction)
daTransactionIdSequence.update(dtTransactionIdSequence)
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
 
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.
 
Back
Top