VB.Net 'Caught Exception' error re-occuring

  • Thread starter Thread starter anthony
  • Start date Start date
A

anthony

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 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.
 
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.
 
Back
Top