|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
Quote:
Provide some code to look at otherwise there's no question here.
__________________
Keep it Prodigy, Keep it Real |
|
#3
|
|||
|
|||
|
Quote:
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, |
|
#4
|
|||
|
|||
|
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 ******************************************* |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Validation of Textbox |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|