|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB.Net 'Caught Exception' error re-occuringNew to vb.net! What's the best way to handle this scenario:
I have a vb.net app (SQL Server DB). When 2 or more users are running the app simultaneously, I recently keep getting: 'Caught Exception': The statement has been terminated'. Violation of Primary Key Constraint. Cannot insert duplicate key in... What's the best way to code that Try/Catch Block. Thanks, ..net newbie The issue is not so much with your try catch block, although you could use
it to fix the problem, if it is happening whenever more then one user is on you have a problem with the database design as you are not incrementing your primary key. Show quote "anthony" <newton***@gmail.com> wrote in message news:1160671727.240155.122450@k70g2000cwa.googlegroups.com... > New to vb.net! What's the best way to handle this scenario: > I have a vb.net app (SQL Server DB). When 2 or more users are running > the app simultaneously, I recently keep getting: 'Caught Exception': > The statement has been terminated'. Violation of Primary Key > Constraint. Cannot insert duplicate key in... > > What's the best way to code that Try/Catch Block. Thanks, > .net newbie > The P-Key is incrementing, but the form is so long that sometimes user
#2 will attempt to add a new record and get the same P-Key as user #1 because user #1 is not finished adding information yet. Any ideas? Thanks. Max wrote: Show quote > The issue is not so much with your try catch block, although you could use > it to fix the problem, if it is happening whenever more then one user is on > you have a problem with the database design as you are not incrementing your > primary key. > > > "anthony" <newton***@gmail.com> wrote in message > news:1160671727.240155.122450@k70g2000cwa.googlegroups.com... > > New to vb.net! What's the best way to handle this scenario: > > I have a vb.net app (SQL Server DB). When 2 or more users are running > > the app simultaneously, I recently keep getting: 'Caught Exception': > > The statement has been terminated'. Violation of Primary Key > > Constraint. Cannot insert duplicate key in... > > > > What's the best way to code that Try/Catch Block. Thanks, > > .net newbie > > |
|||||||||||||||||||||||