We help IT Professionals succeed at work.
Get Started

Handle SQLExceptions in Data Access Layer and pass error to the View(user)

MSFanboy
MSFanboy asked
on
981 Views
Last Modified: 2012-05-10
Hello,

I would like to know what is the best practice in this case:

Customer`s firstname + lastname has a unique index so if I do insert the same name again I get a constraint exception (update exception). in my Repository. What is no the best way to show a user a message box saying update failed because customer already exists?

Do the InserCustomer with a return code like

In my presenter/viewmodel
int updateStatus = repository.CreateCustomer()

if(updateStatus == -1)
show message...
Comment
Watch Question
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE