June 8, 2009 at 3:06 pm
my web app:
Protected Sub Execute_Clicked(ByVal sender As Object, ByVal e As EventArgs)
Dim objConn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection()
objConn.ConnectionString = "server=XXX; database=XXX; uid=XXX; pwd=XXX;"
objConn.Open()
Dim objCmd As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand("SchCorrectDstAcctUnits",objConn)
objCmd.CommandType = System.Data.CommandType.StoredProcedure
objConn.Close()
END Sub
my stored procedure:
USE [XXX]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[SchCorrectDstAcctUnits]
AS
DECLARE @myERROR int -- Local @@ERROR
, @myROWCOUNT int -- Local @@ROWCOUNT
SET NOCOUNT ON
BEGIN TRAN
UPDATE TIMERECORD
SET [DST_ACCT_UNIT] = LEFT([TIMERECORD].[PAY_CODE],3)+SUBSTRING([TIMERECORD].[DST_ACCT_UNIT],4,15)
WHERE TIMERECORD.BATCH_NBR = 88888
AND PAY_CODE <> '2278'
SELECT @myERROR = @@ERROR, @myROWCOUNT = @@ROWCOUNT
IF @myERROR != 0 GOTO HANDLE_ERROR
COMMIT TRAN -- No Errors, go ahead and process
RETURN @myERROR
HANDLE_ERROR:
ROLLBACK TRAN
RETURN @myERROR
===========================
The stored procedure returns @myERROR. How do i grab that value in my webapp and check for error? 0 = successful and update Status.Text to "Update ran successfully!". Thanks in advance.
June 8, 2009 at 4:18 pm
You'll need to execute the query, check out objCmd.ExecuteScalar()
June 9, 2009 at 2:20 pm
Got it. thanks for the help!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply