473,325 Members | 2,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

datatable update error (does update instead of insert)

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
1 1581
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Allan Bredahl | last post by:
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...
5
by: Bhavna | last post by:
Hello I want to push the data in my datatable into my database. How must i do this? I have been told to create a insert query. I have done this and have a select statement below it to retrieve the...
5
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
2
by: Ev | last post by:
I have a database table in SQL Server that has a self join. In C# I have a DataTable with a self-join. I have defined a foreign key constraint on the DataTable for the self join. The...
11
by: Geoff | last post by:
Hi I have a DataTable with thousands of rows. I want a quick way to insert the rows into a table in an Access database with the same structure. I have been using an update command but found it...
20
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've...
0
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: ...
7
by: Kevin | last post by:
I'm new to ADO.NET--trying to make the switch from ADO, which I've been using in my VB2005 apps up until now. Here's what I have: Sub Save_Record() Dim OldRecord as DataTable Dim NewRecord as...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.