Active Server Pages Programming (ASP)/Error Number

Advertisement


Question
-------------------------
Followup To
Question -
Unique key constraint set in a table of SQL Database.  When user attempt to save a record by adding or editing with the duplicate key; an message box should come on page indicating that id is already present in table (as per error number error handling).  Please guide me.
Thanks in advance.
Regards

Answer -
Hi

Before saving the entry.. You have to check whether that key exsits in the database using

select count(key) from tablename where key = inputkey

if you get 0(zero) means key not exists otherwise key exists...

Happy Programming!!

-srini


Thank you very much for your quick and workable reply but; sir one thing is that if there is already id is in table a message box should come with messaging "id is already in table. Do you want to correct it or cancel."  I m not able to get a message box.
Please favour me.

Answer
Hi

Here is the workflow

if someinput = "1"
    overwrite / or update

end if

IF count = 0 then
   insert
else if
   <script>
         var sval = confirm("found overwirte")
         if (sval)
         document.form.someinput.value = "1"
         document.form.submit
    </script>
end if


Happy programming!

-srini

Active Server Pages Programming (ASP)

All Answers


Answers by Expert:


Ask Experts

Volunteer


Srini Nagarajan

Expertise

I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase

Experience

Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.

©2012 About.com, a part of The New York Times Company. All rights reserved.