Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Q: primary key is stored in separate table
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01268162
Message ID:
01268585
Views:
11
Anatolly,

>The primary key for ORDERS table is stored in PKEYS table.
>
>The steps for inserting new ORDERS record:
>
>1. read the latest primary key value from PKEYS table, increase by 1
>2. in ORDERS DataSet update Table(0).Rows(0).Item("order_id") with the new value
>3. use SaveDataSet to save the dataset
>4. if successful, save the new primary key value in PKEYS table
>
>Without wrapping in transaction, the above steps fail when several users add orders simultaneously. Could be using the RegisterChildBizObj the better practice or TRIGGER AFTER INSERT can help?
>
>Your help is very much appreciated.

I highly recommend using database-generated primary keys instead. I'm guessing you are running into problems with multiple users trying to get a new primary key at the same time.

Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform