• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 138
  • Last Modified:

How to use error info in data access layer to trigger message to user

I have a delete method for a table that doesn't work when the key from that table is associated with records in another table. When the user attempts to delete a one of these records, a sql exception number 547 is thrown in the data access layer. When this error number is thrown, I want to notify the user of what is going on. I figured I could just store the error number in a session variable and check for it when the code got back to the procedure that called the delete method in the data access layer, but I can't create a session variable there - I guess because it's a seperate class. Anyway, how can I get the error number back to the calling procedure so I can check for it? I'm figuring there is some standard way that people use that I'm not aware of. Thanks.

0
Feyo
Asked:
Feyo
  • 2
  • 2
1 Solution
 
prakash_prkCommented:
best you can use exceptions.

throw an exception from the DAL part.
catch the exception in the called procedure.
display the message

you can use the session varibales by httpcontext . but it is not advisable

System.Web.HttpContext.Current.Session

Regards
prakash
0
 
FeyoAuthor Commented:
Should I be able to catch that exception where I call the procedure? For some reason, it's not catching.
0
 
prakash_prkCommented:
did u directly call the DAL?
can u post a sample code?
0
 
FeyoAuthor Commented:
This does seem to work. Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now