Link to home
Start Free TrialLog in
Avatar of Gunit2507
Gunit2507

asked on

Updating Datasets

I have a program that will be running on multiple computers are the same time. The program uses a dataset which stores the diffrent sticker number. More stickers can be added, where the StickerNo is the primary key because it needs to be unuiqe. I am running into a problem though. For example both program one and program two went through the startup process and all the information is stored into the datasets. Program one stores more records into the database. Then program two stored more records, one being with the same StickerNo. Because the datasets have never been updated since the new records are added, two records with the same PK (StickerNo) are added, and no exception is thrown. I need to figure out how to avoid this. ANY suggestions would help!
Avatar of SandeepRR
SandeepRR
Flag of United States of America image

HI Gunit2507,
        I am not getting why the error is not thrown, can please check the datatable design again i. e the primary key and all,

and for the problem what u can do set the 'StickerNo' as identity colun i.e it will generate automatically and while entring the data the column will take the next value of the " max value + 'Identity Seed' " value, set it to one so that it increments by one,
and while adding the data to DB dont generate the 'StickerNo' in backend only send all the column values except 'StickerNo' and the new row will be added with unique 'StickerNo' .

SandeepRR
ASKER CERTIFIED SOLUTION
Avatar of Manish Chhetia
Manish Chhetia
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gunit2507
Gunit2507

ASKER

Hello,

StickerNo is the primary key in the database and dataset, it is also set to be unique and does not accept DBNull values. It is also indexed with no duplicates. The StickerNo field will not necessarly be straight 1, 2, 3, 4, 5... It might be skipping numbers and such, and the records can't just be empty. Thats why I want to be able to enter the StickerNo.