?
Solved

Updating Datasets

Posted on 2006-05-25
3
Medium Priority
?
174 Views
Last Modified: 2010-04-23
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!
0
Comment
Question by:Gunit2507
3 Comments
 
LVL 6

Expert Comment

by:SandeepRR
ID: 16766513
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
0
 
LVL 6

Accepted Solution

by:
manch earned 2000 total points
ID: 16766573
Define the primay column on the dataset as given below :
(And then update the dataset  it will automatically take care of duplicacy)
(Use adapter to update the dataset with command objects)


            Dim pcol(0) As DataColumn
            pcol(0) = dataset.Tables("TableName").Columns("ColumnName")
            dataset.Tables("ColumnName").PrimaryKey = pcol
0
 

Author Comment

by:Gunit2507
ID: 16773674
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question