none
catching exception on primary key violation RRS feed

  • Question

  • hi all,

    scenario:
    i have a database of employee details (like empID, empFisrtName, empLastName etc), with empID as primary key.
    On the client side(GUI) authenticated users can add more employees to the database by entering above details.

    now  while adding new employee if the user erroneously enters empID which already exists in database(primary key violation) an exception will be thrown.

     

    instead showing this exception i want to display my own error message...


    how do i go ahead??

    using C# asp.net

    pls help

                              
    Tuesday, September 23, 2008 1:09 AM

Answers

  • You don't have to display the message from the exception. Just use your Try...Catch block to catch the exception and display your own message in the web page.
    Wednesday, September 24, 2008 2:16 PM

All replies

  • This is not the right forum for this question moving to "ADO.NET Data Providers forum.
    Wednesday, September 24, 2008 3:14 AM
  • You don't have to display the message from the exception. Just use your Try...Catch block to catch the exception and display your own message in the web page.
    Wednesday, September 24, 2008 2:16 PM
  • I have a web form and I got an error: primary key violation duplicate ... I want  to display user friendly  error message - using C#.
    Any suggestions?
    Tuesday, December 2, 2008 11:13 PM