Key not auto-incrementing when updating from a dataset
Posted by: David Donahue
Date: February 16, 2005 02:13PM

I'm using the code found at http://www.codeproject.com/aspnet/image_asp.asp to store images in my database, but I've modified it to use the ByteFX data provider (the older one, since it works with Mono which I'm using to host my site). The only problem I'm having is that, when I fill a dataset from a table and add a record to the dataset and use it to update the table, the update fails with an error telling me that the primary key can not be null.

The primary key for this table is an auto-incrementing integer and does its job just fine with regular "INSERT INTO..." statements. And I've been told that the code (exactly as it is written) on the aforementioned webpage also performs the task just fine. So I'm wondering if there might be anything about the ByteFX data provider that I might have to tweak to accomplish this.

I've tried adding the key field to the new data row and assigning it "null" or an empty string, but those always return errors. Has anyone experienced this before? Can anyone think of what I would need to do to achieve the desired results?

The only other thing i can think of is to grab the highest key from the table and increment it in my .NET code and post the new record with that. But then a race condition would become possible if two people are posting at the same time.

Any ideas?


Regards,
David P. Donahue
ddonahue@ccs.neu.edu

Options: ReplyQuote


Subject
Written By
Posted
Key not auto-incrementing when updating from a dataset
February 16, 2005 02:13PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.