PDA

View Full Version : Duplicate Row - error message



Berthadoms
07-26-2015,
Hi All, I have a web form that inserts information into two tables in sql 2005 database on a submit button click. I have a unique key on the tables preventing duplicate information which works fine. The problem I have is that at the minute if a users tries to insert a duplicate row they just get the built in sql error message. Is there a way I can validate the information before if goes into the database and display perhaps a label telling the user of their error or is there a way I can customize the build in sql error message? I've had a search on various forums and sites and can't find any info that would help me.

Thanks in advance

bestciglier
07-27-2015,
Were the responses to your previous thread on this (http://forums.devshed.com/net-development-87/custom-error-messages-497034.html) insufficient?

bgbhyyqqvo
07-28-2015,
Nothing is preventing you from requerying your database to see if it already contains a key prior to inserting a duplicate.

BillBohackSCAMSi
07-31-2015,
I don't know what your code looks like, but since its a webform that apparently takes user input, then you should try using a custom validator control (http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.aspx) and check for key violations in the controls ServerValidate event.

bhusndqfub
07-31-2015,
No. try it...