jordanking
Programmer
- Sep 8, 2005
- 351
hello,
I have a asp.net 3.5 website that has a sql server 2005 backend. I have a stored procedure that accepts a couple of parameters and returns an integer value. The procedure runs fine when executed from SQL management studio, but I can not capture the return values on the asp side. The following is mey procedure with asp code.
SQL Stored Procedure
Asp Code that runs the procedure
I can not get the procedure's return values. Can anyone help me debug this?
thanks in advance
.....
I'd rather be surfing
I have a asp.net 3.5 website that has a sql server 2005 backend. I have a stored procedure that accepts a couple of parameters and returns an integer value. The procedure runs fine when executed from SQL management studio, but I can not capture the return values on the asp side. The following is mey procedure with asp code.
SQL Stored Procedure
Code:
ALTER PROCEDURE [dbo].[EFFU_Validate_Membership]
@FirstName nvarchar(50),
@LastName nvarchar(50),
@IAFF int,
@Validated int OUTPUT
AS
BEGIN
-- Insert statements for procedure here
SELECT intIAFF, chrFirst, chrLast, blnActive
FROM Member
WHERE (intIAFF = @IAFF) AND (chrFirst = @FirstName) AND (chrLast = @LastName)
IF @@ROWCOUNT = 1 SELECT @Validated = 1
ELSE SELECT @Validated = 0
RETURN @Validated
END
Asp Code that runs the procedure
Code:
Protected Sub btn_SignUp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_SignUp.Click
Dim intIAFF As Integer
Dim chrFirst As String
Dim chrLast As String
Dim intValidated As Integer
Dim iRet As Integer
''VALIDATE USER INPUT
If IsNumeric(txtIAFF.Text) = True Then
intIAFF = Convert.ToInt32(txtIAFF.Text)
End If
If txtFirst.Text = String.Empty Then
lblError.Text = "Please Enter a First Name"
Exit Sub
Else
chrFirst = txtFirst.ToString.ToLower
End If
If txtLast.Text = String.Empty Then
lblError.Text = "Please Enter a Last Name"
Exit Sub
Else
chrLast = txtLast.ToString.ToLower
End If
''CHECK SQL FOR MEMBERSHIP VALIDATION AND SET SESSION VARIABLES
''define and open connection referencing web.config for connection string
Dim cs As String = ConfigurationManager.ConnectionStrings("EFFU_Main").ConnectionString
Using con As New System.Data.SqlClient.SqlConnection(cs)
con.Open()
''define the command object
Dim cmd As New System.Data.SqlClient.SqlCommand
cmd.Connection = con
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.CommandText = "EFFU_Validate_Membership"
''define and populate the parameters
cmd.Parameters.Add("@FirstName", Data.SqlDbType.NVarChar, 50)
cmd.Parameters("@FirstName").Value = chrFirst
cmd.Parameters.Add("@LastName", Data.SqlDbType.NVarChar, 50)
cmd.Parameters("@LastName").Value = chrLast
cmd.Parameters.Add("@IAFF", Data.SqlDbType.Int)
cmd.Parameters("@IAFF").Value = intIAFF
cmd.Parameters.Add("@Validated", Data.SqlDbType.Int)
cmd.Parameters("@Validated").Direction = Data.ParameterDirection.Output
''read results of stored procedure;
cmd.ExecuteNonQuery()
intValidated = CInt(cmd.Parameters("@Validated").Value)
''close connection
con.Close()
End Using
''REDIRECT TO APPRORIATE PAGE
If intValidated = 1 Then
lblError.Text = "User Validated"
Else
lblError.Text = "User Not Validated"
End If
End Sub
I can not get the procedure's return values. Can anyone help me debug this?
thanks in advance
.....
I'd rather be surfing