Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 12th, 2006, 04:46 PM
whitelm whitelm is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 13 whitelm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 32 m 18 sec
Reputation Power: 0
Cool Validation of Textbox

I am using VB.NET (2003) to create a Windows form to interface with a SQL 2000 database. I need to validate the user input of an employee number with the table that contains the valid numbers. All I want to do is validate the information and move on, or pop a messagebox up. My problem is getting the code right to loop the array for the comparison function.

I also hope to match the USERID and integrate this into the validation process to further verify that the proper person is being identified.

Thank you in advance.

LW

Reply With Quote
  #2  
Old July 19th, 2006, 03:43 PM
ProEdge's Avatar
ProEdge ProEdge is offline
Contributing User
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2004
Location: Somewhere I belong
Posts: 1,565 ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 17 h 7 m 15 sec
Reputation Power: 39
Quote:
Originally Posted by whitelm
I am using VB.NET (2003) to create a Windows form to interface with a SQL 2000 database. I need to validate the user input of an employee number with the table that contains the valid numbers. All I want to do is validate the information and move on, or pop a messagebox up. My problem is getting the code right to loop the array for the comparison function.

I also hope to match the USERID and integrate this into the validation process to further verify that the proper person is being identified.

Thank you in advance.

LW

Provide some code to look at otherwise there's no question here.
__________________
Keep it Prodigy, Keep it Real

Reply With Quote
  #3  
Old July 19th, 2006, 04:07 PM
whitelm whitelm is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 13 whitelm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 32 m 18 sec
Reputation Power: 0
Smile Code

Quote:
Originally Posted by ProEdge
Provide some code to look at otherwise there's no question here.


That's the problem. My existing code probably does not make any sense, as it doesn't work as intended. I can pose the question logically though. I have a Windows form created in VB.NET, that asks for a users ID number. I have a table in the SQL database that contains all employees ID numbers. I need to validate the entry, by the user, in the textbox and either successfully move onto the next textbox, or pass the user a messagebox stating it was invalid. Capturing the textbox variable is easy:

Dim n As String
n = editEMPLID.Text

Creating the messagebox code is fairly easy, I have:

If Not (M = n) Then
MessageBox.Show("Employee number " & n & " could not be found or You have" _
& " entered an invalid employee ID number.", "Please try again!")
Return False
Else
MessageBox.Show("Your employee ID number " & n & " has been verified", "Your order for LAMB CHOPS " _
& Today & " has been validated!")
Return True
End If

I guess the question I have is: How do you get the results of the SQL SELECT statement in a proper form to compare to the entry in the editEMPLID.Text (textbox)? My guess is I need to capture as an array and have it scan through the array and either find it or not?

Thank you,

Reply With Quote
  #4  
Old July 19th, 2006, 04:57 PM
whitelm whitelm is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 13 whitelm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 32 m 18 sec
Reputation Power: 0
Cool Validate Textbox Code

Eureka! I think I found it. It may not be the neatest code, but it works.
**********************************************
Private Function isEmpExist(ByVal EmpNo As Integer) As Boolean
Dim CN As New SqlConnection
Dim n As String
Dim m As String
n = editEMPLID.Text
CN = New SqlConnection("Integrated Security=False; User id= testuser; password= xxxxx; Server=x.x.x.x; Initial Catalog=Galley")
Dim Cmd As SqlCommand = CN.CreateCommand

With Cmd
.CommandText = ("SELECT emplid FROM users WHERE emplid = 'n'")
CN.Open()
m = values10.Contains(n)
CN.Close()
MyConnection1.Close()
End With

If Not m = True Then
MessageBox.Show("Employee number " & n & " could not be found or You have" _
& " entered an invalid employee ID number.", "Please try again!")
Else
MessageBox.Show("Your employee ID number " & n & " has been verified", "Your order for " _
& Today & " has been validated!")
End If

End Function
*****************************************
Private Sub editEMPLID_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles editEMPLID.Leave
isEmpExist(1)
End Sub
*******************************************

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Validation of Textbox


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT