[thelist] Calling a sproc from VB
Anthony Baratta
anthony at baratta.com
Wed Feb 4 12:48:30 CST 2004
At 10:33 AM 2/4/2004, Tab Alleman wrote:
>How can I see what the error is inside the sproc when I am calling the
>sproc from the VB app?
Are you doing any error trapping in your SP? e.g.
e.g.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CREATE PROCEDURE [dbo].[sp_AddCustomer]
@CustomerName as varchar(50),
@CustomerNumber as varchar(20),
@CustomerStatus as varchar(12),
@AdminUser as varchar(20)
AS
INSERT INTO Customers (
CustomerNumber
,Name
,Status
,InsertDateTime
,InsertUserID
,UpdateDateTime
,UpdateUserID
)
VALUES (
@CustomerNumber
, at CustomerName
, at CustomerStatus
,GetDate()
, at AdminUser
,GetDate()
, at AdminUser
)
IF (@@ERROR <> 0)
SELECT 0 AS CustomerID, @@ERROR AS SQLErrorLevel, 'Insert Failed'
as ErrorMessage
ELSE
SELECT @@IDENTITY as CustomerID
GO
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This way you check the return value, and if it's Zero there has been a failure.
---
Anthony Baratta
President
Keyboard Jockeys
"Conformity is the refuge of the unimaginative."
More information about the thelist
mailing list