|
-
Dec 5th, 2000, 09:06 AM
#1
Thread Starter
Junior Member
Hi there,
I am new to VB and is trying to create a login application. I currently have a form with two text boxes (txtUserName and txtPassword) and a submit button, right now I am able to validate the user name and password but I have to hard coded both of the UserName and Password in my code(not very efficient). I want to be able to validate users' input against my database, I have a table in Access with the following fields: Id, UserName, Password. I know I need to write a SQL statement but I don't know how to compare the result of the query to the value of the 2 text boxes. I am posting what i have, can someone be kind enough to take a look and point me in the right direction? TIA.
frmLogIn
Option Explicit
Private strPassword As String
Private Sub cmdLogIn_Click()
If (UCase(txtName.Text) = "SUNSHINE" And UCase(strPassword) = "HELLO") Or _
(UCase(txtName.Text) = "SNOWY" And UCase(strPassword) = "TEST") Then
frmMenu.Show
Unload Me
Else
MsgBox "Sorry" & First(txtName.Text) & ", incorrect password please try again.", vbApplicationModal, "Incorrect Password"
Call ClearText
End If
End Sub
Private Sub cmdReset_Click()
End
End Sub
Private Sub txtPassword_Change()
Dim I As Integer
For I = 1 To Len(txtPassword.Text)
If Mid(txtPassword.Text, I, 1) <> "*" Then
strPassword = strPassword + Mid(txtPassword.Text, I, 1)
txtPassword.Text = Mid(txtPassword.Text, 1, I - 1) + "*"
End If
Next I
End Sub
Public Function First(Name As String) As String
Dim I As Integer
For I = 1 To Len(Name)
If Mid(Name, I, 1) = "" Then
First = Mid(Name, 1, I - 1)
Exit Function
End If
Next I
First = Name
End Function
Private Sub ClearText()
txtName.Text = ""
txtPassword.Text = ""
strPassword = ""
txtName.SetFocus
End Sub
-
Dec 5th, 2000, 09:13 AM
#2
Frenzied Member
your sql statement
SQL = "SELECT * FROM Users WHERE User = " & txtUserName.text & " AND Password = " & txtpassword.text
do you know how to use ado?
if you want you can send me your app with db
i will write it up for ya and send it back
if you need more help post
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|