473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

CustomValidator Control troubles

Hi All.

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 it to invalidate the page, the code fails. What am I missing???? 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

*******************************

Jul 21 '05 #1
0 887

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bill yeager | last post by:
I'm using the customvalidator in my web page. I get the following error when I try to run the web page: Unable to find control id 'lstRider' referenced by the 'ControlToValidate' property of...
0
by: Jim Heavey | last post by:
Hello, I have added a "CustomValidator" control in in code to a control which is already on the footer. I am running the validation for the control at the server. My problem is that when the...
1
by: Dan Sikorsky | last post by:
I'm getting the following message when I try to add a CustomValidator control to the ValidationSummary to display an error message at runtime, and displaying ex.message in AddValidationControl...
0
by: ghafranabbas | last post by:
This is how you use the customvalidator control in any INamingContainer interface control (Datagrid, DataList, DataRepeater, etc). 1. In the ItemTemplate, place your customvalidator 2. Set the...
1
by: Nathan Sokalski | last post by:
I want to make sure that the SelectedDate property of the Calendar control is later than the current date or that a certain checkbox is selected. I tried to use a CustomValidator control with the...
0
by: Philip Korolev | last post by:
Hi All. 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
by: Philip Korolev | last post by:
Hi All. 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...
1
by: David | last post by:
I need help with CustomValidator in 1.1. I added the CustomValidator control and code as per the doc., (See below) However, the code is never executed. Is there an extra switch or setting to...
3
by: Stan SR | last post by:
Hi, I have a web user control that contains 3 dropdownlists it's a date selector, so one contains the days, one the months and the last the years. Each of them starts with a blank value. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.