P
Philip Korolev
Hi All. Tore most of my hair out trying to solve this already! Please allow me to keep the remaining two
What I am trying to do is use customValidator to go to a database via a stored procedure and fish out a UserName value. If it finds it, I want it to return 1 and if not I want it to return 0. On the ASP.NET page I have a field called user_username that customValidator is pointing to as a control to validate. The subroutine for the validator and my stored procedure are below. I now have 37 instances of the username = pkorolev and I get 37 as the value returned by the stored procedure, however the point where I want the validator to invalidate the page, the code fails. So, I get a correct value returned by the database (Enterprise Manager test), I get this value correctly on the ASPX page as output but the IsValid bit fails. What am I missing, seetings perhaps???? I bet it is something really simple.
***********************
create procedure userAlreadyExists
@user_username nvarchar(100),
@valid int output
as
declare @userValid int
select @userValid = Count(*) from user_pass
where user_username = @user_username
set @Valid = convert(int, @userValid) -- in this line i am simply trying to ensure that value coming back as an iteger
**********************
CustomValidator SUB:
*********************
Private Sub custValUserExists_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles custValUserExists.ServerValidate
Dim cnn As New SqlConnection(connection.SQlConnection)
Dim sdrUserExists As SqlDataReader
Dim cmdUserExists As New SqlCommand("userAlreadyExists", cnn)
Dim ctrlValue As Integer
Try
cnn.Open()
cmdUserExists.CommandType = CommandType.StoredProcedure
cmdUserExists.Parameters.Add("@user_username", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Input
cmdUserExists.Parameters("@user_username").Value = Trim(art_username.Text)
cmdUserExists.Parameters.Add("@Valid", SqlDbType.Int).Direction = ParameterDirection.Output
cmdUserExists.ExecuteNonQuery()
'the line below is for checking the value returned on the confirmation page
Session("DBRETVAL") = cmdUserExists.Parameters("@Valid").Value
If cmdUserExists.Parameters("@Valid").Value = 0 Then
args.IsValid = True
Else
args.IsValid = False
End If
Catch ex As Exception
lbltype.Text = ex.ToString
End Try
End Sub
*******************************
What I am trying to do is use customValidator to go to a database via a stored procedure and fish out a UserName value. If it finds it, I want it to return 1 and if not I want it to return 0. On the ASP.NET page I have a field called user_username that customValidator is pointing to as a control to validate. The subroutine for the validator and my stored procedure are below. I now have 37 instances of the username = pkorolev and I get 37 as the value returned by the stored procedure, however the point where I want the validator to invalidate the page, the code fails. So, I get a correct value returned by the database (Enterprise Manager test), I get this value correctly on the ASPX page as output but the IsValid bit fails. What am I missing, seetings perhaps???? I bet it is something really simple.
***********************
create procedure userAlreadyExists
@user_username nvarchar(100),
@valid int output
as
declare @userValid int
select @userValid = Count(*) from user_pass
where user_username = @user_username
set @Valid = convert(int, @userValid) -- in this line i am simply trying to ensure that value coming back as an iteger
**********************
CustomValidator SUB:
*********************
Private Sub custValUserExists_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles custValUserExists.ServerValidate
Dim cnn As New SqlConnection(connection.SQlConnection)
Dim sdrUserExists As SqlDataReader
Dim cmdUserExists As New SqlCommand("userAlreadyExists", cnn)
Dim ctrlValue As Integer
Try
cnn.Open()
cmdUserExists.CommandType = CommandType.StoredProcedure
cmdUserExists.Parameters.Add("@user_username", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Input
cmdUserExists.Parameters("@user_username").Value = Trim(art_username.Text)
cmdUserExists.Parameters.Add("@Valid", SqlDbType.Int).Direction = ParameterDirection.Output
cmdUserExists.ExecuteNonQuery()
'the line below is for checking the value returned on the confirmation page
Session("DBRETVAL") = cmdUserExists.Parameters("@Valid").Value
If cmdUserExists.Parameters("@Valid").Value = 0 Then
args.IsValid = True
Else
args.IsValid = False
End If
Catch ex As Exception
lbltype.Text = ex.ToString
End Try
End Sub
*******************************