Newbie Help with return value

  • 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.

  • You'll need to execute the query, check out objCmd.ExecuteScalar()

  • 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