Controlling a primary key column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello:
I have an application with a data base. i insert information by the
application in the data base, and i have to control that the user doesn't
give a value for the primary key column that already exists.
I would want to know what happens in that case, when you try to insert a new
row in the table with a value for the primary key that already exists, an
exception is raised? nothing happens? it happens an updated?
Thanks for the help.
Bye.
 
The same thing happens that would happen if you were to run the query
directly on the database.

The row would not get added, and an error would be raised.

What your application should do, is to check whether or not the primary key
the user provided is already taken or not. If not, proceed. Otherwise, show
the user an error message.
 
Hello:
I use SQL Server Desktop Edition in a PocketPC client, and i have a similar
code in the server, but in the server i use DBF (make with Visual FoxPro, i
believe) by OleDb connector. I execute the command directly, i create the SQL
sentence in a string, load it in the Command and then call to
executeNonQuery method.
Thanks for your help.
Bye.
 
Hello:
I had though about what you tell me, but i see a problem, i would have to do
two access to the database, and this will penalize the performance, specially
in the PocketPC application. That's because i prefer to control the exception
raised or a similar solution solution instead of accesing two times to the
database.
Thank you for your help.
Bye.
 
Back
Top