473,394 Members | 1,696 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,394 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

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

Nov 22 '05 #1
0 737

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

Similar topics

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: Jose Fernandez | last post by:
Hola I have this customvalidator <asp:CustomValidator id="ComboValidator" runat="server" ErrorMessage="CustomValidator" /> (The OnServerValidate method is set in Events windows of the Control...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.