One of my developers came to me with this question and I don't have an
answer for them. The only suggestion I had for them was to change the
return to a output parameter and put a try catch around it and look for the
output parameter to have a value.
I would have thought this should have been posted in the sql newgroups, but
I know exactly what they would say, and they would be correct.
But when using asp.net ado.net command object. I am running a sproc that
handles its own errors gracefully and will sets the output parameter @msg to
a successful, or unsucessful message.
And it does return it when I run the sproc in query analyzer.
However, when I run the code in asp.net the Execute method for the Command
object throws and exception so I never get the status.
Is there a way in a stored procedure to clear the error so it doesn't
through an exception through the ado.net object?
bill
<sproc snippet>
Insert Into tblTPA
Values( @FinalID, GetDate(), @InAuditor, @Type, @Comments, @Hours,
@Expenses, @DinersExpenses)
if @@Error <> 0
BEGIN
ROLLBACK
Set @msg = 'The final timesheet you tried to save was already saved by
another user.'
END
else
BEGIN
COMMIT
Set @msg = 'The final timesheet has been saved.'
END
Select @msg 4 1623
William,
The real problem here is that your stored procedure isn't really handling
the error condition "gracefully". Known potential error conditions that
should not be treated as application exceptions should not be allowed to
occur at all. If you don't want any part of your application treating this
potential duplicate insertion scenario as an exception, test for it in the
stored procedure before the insertion attempt. e.g.:
IF <final timesheet has already been saved>
SET @msg = 'The final timesheet you tried to save was already saved by
another user.'
ELSE
BEGIN
INSERT INTO...
IF @@ERROR <> 0 SET @msg = 'An unexpected error occurred.'
...
END
HTH,
Nicole
"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:ei**************@TK2MSFTNGP09.phx.gbl... One of my developers came to me with this question and I don't have an answer for them. The only suggestion I had for them was to change the return to a output parameter and put a try catch around it and look for
the output parameter to have a value.
I would have thought this should have been posted in the sql newgroups,
but I know exactly what they would say, and they would be correct.
But when using asp.net ado.net command object. I am running a sproc that handles its own errors gracefully and will sets the output parameter @msg
to a successful, or unsucessful message.
And it does return it when I run the sproc in query analyzer.
However, when I run the code in asp.net the Execute method for the Command object throws and exception so I never get the status.
Is there a way in a stored procedure to clear the error so it doesn't through an exception through the ado.net object?
bill
<sproc snippet>
Insert Into tblTPA
Values( @FinalID, GetDate(), @InAuditor, @Type, @Comments, @Hours, @Expenses, @DinersExpenses)
if @@Error <> 0
BEGIN
ROLLBACK
Set @msg = 'The final timesheet you tried to save was already saved by another user.'
END
else
BEGIN
COMMIT
Set @msg = 'The final timesheet has been saved.'
END
Select @msg
On Fri, 24 Oct 2003 16:44:49 -0500, "William F. Robertson, Jr."
<wf*********@kpmg.com> wrote: One of my developers came to me with this question and I don't have an answer for them. The only suggestion I had for them was to change the return to a output parameter and put a try catch around it and look for the output parameter to have a value.
I would have thought this should have been posted in the sql newgroups, but I know exactly what they would say, and they would be correct.
But when using asp.net ado.net command object. I am running a sproc that handles its own errors gracefully and will sets the output parameter @msg to a successful, or unsucessful message.
And it does return it when I run the sproc in query analyzer.
However, when I run the code in asp.net the Execute method for the Command object throws and exception so I never get the status.
Is there a way in a stored procedure to clear the error so it doesn't through an exception through the ado.net object?
bill
<sproc snippet>
Insert Into tblTPA
Values( @FinalID, GetDate(), @InAuditor, @Type, @Comments, @Hours, @Expenses, @DinersExpenses)
if @@Error <> 0
BEGIN
ROLLBACK
Set @msg = 'The final timesheet you tried to save was already saved by another user.'
END
else
BEGIN
COMMIT
Set @msg = 'The final timesheet has been saved.'
END
Select @msg
Would it be better for the stored proc to raise an exception of it's
own? You can specify the message, to be user friendly, and will be
able to access it in the catch block. This will work with sql server
2K, I wouldn't know about previous versions.
A further point is that there are some errors you can't trap -
duplicate key being one, so if you want nice messages for this the
stored proc must detect that it was going to happen and not try the
insert.
Yes, you were right, that was the real problem.
I should have seen that.
Thanks,
bill
"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:em*************@TK2MSFTNGP10.phx.gbl... William,
The real problem here is that your stored procedure isn't really handling the error condition "gracefully". Known potential error conditions that should not be treated as application exceptions should not be allowed to occur at all. If you don't want any part of your application treating
this potential duplicate insertion scenario as an exception, test for it in the stored procedure before the insertion attempt. e.g.:
IF <final timesheet has already been saved> SET @msg = 'The final timesheet you tried to save was already saved by another user.' ELSE BEGIN INSERT INTO... IF @@ERROR <> 0 SET @msg = 'An unexpected error occurred.' ... END
HTH, Nicole
"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message news:ei**************@TK2MSFTNGP09.phx.gbl... One of my developers came to me with this question and I don't have an answer for them. The only suggestion I had for them was to change the return to a output parameter and put a try catch around it and look for the output parameter to have a value.
I would have thought this should have been posted in the sql newgroups, but I know exactly what they would say, and they would be correct.
But when using asp.net ado.net command object. I am running a sproc that handles its own errors gracefully and will sets the output parameter
@msg to a successful, or unsucessful message.
And it does return it when I run the sproc in query analyzer.
However, when I run the code in asp.net the Execute method for the
Command object throws and exception so I never get the status.
Is there a way in a stored procedure to clear the error so it doesn't through an exception through the ado.net object?
bill
<sproc snippet>
Insert Into tblTPA
Values( @FinalID, GetDate(), @InAuditor, @Type, @Comments, @Hours, @Expenses, @DinersExpenses)
if @@Error <> 0
BEGIN
ROLLBACK
Set @msg = 'The final timesheet you tried to save was already saved by another user.'
END
else
BEGIN
COMMIT
Set @msg = 'The final timesheet has been saved.'
END
Select @msg
Yes, you were right, that was the real problem.
I should have seen that.
Thanks,
bill
"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:em*************@TK2MSFTNGP10.phx.gbl... William,
The real problem here is that your stored procedure isn't really handling the error condition "gracefully". Known potential error conditions that should not be treated as application exceptions should not be allowed to occur at all. If you don't want any part of your application treating
this potential duplicate insertion scenario as an exception, test for it in the stored procedure before the insertion attempt. e.g.:
IF <final timesheet has already been saved> SET @msg = 'The final timesheet you tried to save was already saved by another user.' ELSE BEGIN INSERT INTO... IF @@ERROR <> 0 SET @msg = 'An unexpected error occurred.' ... END
HTH, Nicole
"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message news:ei**************@TK2MSFTNGP09.phx.gbl... One of my developers came to me with this question and I don't have an answer for them. The only suggestion I had for them was to change the return to a output parameter and put a try catch around it and look for the output parameter to have a value.
I would have thought this should have been posted in the sql newgroups, but I know exactly what they would say, and they would be correct.
But when using asp.net ado.net command object. I am running a sproc that handles its own errors gracefully and will sets the output parameter
@msg to a successful, or unsucessful message.
And it does return it when I run the sproc in query analyzer.
However, when I run the code in asp.net the Execute method for the
Command object throws and exception so I never get the status.
Is there a way in a stored procedure to clear the error so it doesn't through an exception through the ado.net object?
bill
<sproc snippet>
Insert Into tblTPA
Values( @FinalID, GetDate(), @InAuditor, @Type, @Comments, @Hours, @Expenses, @DinersExpenses)
if @@Error <> 0
BEGIN
ROLLBACK
Set @msg = 'The final timesheet you tried to save was already saved by another user.'
END
else
BEGIN
COMMIT
Set @msg = 'The final timesheet has been saved.'
END
Select @msg
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bill S. |
last post by:
Hi,
I a stored procedure that inserts a record into a table as
below.
The insert works OK, but if the insert violates a unique
indewx constraint on one of the columns, the proc terminates...
|
by: xAvailx |
last post by:
I have a requirement that requires detection of rows deleted/updated by
other processes. My business objects call stored procedures to create,
read, update, delete data in a SQL Server 2000 data...
|
by: dtwilliams |
last post by:
OK, i'm trying to do some error checking on stored procedures and am
following the advise in Erland Sommarskog's 'Implementing Error
Handling with Stored Procedures' document.
Can anybody help...
|
by: Rhino |
last post by:
I've written several Java stored procedures now (DB2 V7.2) and I'd like to
write down a few "best practices" for reference so that I will have them
handy for future development.
Would the...
|
by: Jurgen Defurne |
last post by:
I am currently designing an application which should be accessible from
different interfaces. For this I like to be using stored procedures to
process the contents of form submissions and dialog...
|
by: csgraham74 |
last post by:
Hi guys,
Basically i have been developing in dotnet for a couple of years but
ive had a few issues in regards to error handling.
For example - I have a class that i call passing in a stored...
|
by: pob |
last post by:
>From a form I have some code that calls 4 modules
frmMain
1 mod
2 mod
3 mod
4 mod
If mod 1 experiences an error the error handling works fine within mod
1 and writes out the error to a...
|
by: |
last post by:
I have an application that has a presentation later, business layer, and
data layer. All three projects have their own exception policy, the "UI
Policy", "BL Policy", "DL Policy", all of which...
|
by: barmatt80 |
last post by:
I am stumped on the error reporting with sql server. I was told i
need to return @SQLCode(code showing if successful or not) and
@ErrMsg(and the message returned). I am clueless on this.
I...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: DizelArs |
last post by:
Hi all)
Faced with a problem, element.click() event doesn't work in Safari browser.
Tried various tricks like emulating touch event through a function:
let clickEvent = new Event('click', {...
| |