•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 402,524 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,474 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 2684 | Replies: 8
![]() |
•
•
Join Date: Dec 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
hi
can anyone help me how to compare user and password from a database like access... for example i have registered a user and password in access then when i input the user to VB and the password it will compare if the user exist and if the password is right for that existing user.... just like a log in system...:cheesy:
can anyone help me how to compare user and password from a database like access... for example i have registered a user and password in access then when i input the user to VB and the password it will compare if the user exist and if the password is right for that existing user.... just like a log in system...:cheesy:
Well, I can't go into specifics because I don't know too much about database programming, but I can take a stab at what you'll need to do in order to make it work.
1. Search the database for the entered user name's record. If no match, display a "wrong username" error message. If there is a match:
2. Read that whole user name/password record from the database.
3. Compare the password field to the entered password. If no match, display a "wrong password" error message. If there is a match:
4. Method is complete.
1. Search the database for the entered user name's record. If no match, display a "wrong username" error message. If there is a match:
2. Read that whole user name/password record from the database.
3. Compare the password field to the entered password. If no match, display a "wrong password" error message. If there is a match:
4. Method is complete.
•
•
Join Date: Dec 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
what i mean is what can i use? for example
if cbouser.txt = "the user in the database" then
blah
what can i use for the user choosed in the combo box to be compared in the databassed i made so that it will check if its valid or not...what im trying to make is that it has multiple user that can access to it and differend password each..thanks
if cbouser.txt = "the user in the database" then
blah
what can i use for the user choosed in the combo box to be compared in the databassed i made so that it will check if its valid or not...what im trying to make is that it has multiple user that can access to it and differend password each..thanks
Last edited by darkmessenger : Dec 17th, 2006 at 6:14 pm. Reason: press wrong button XD
•
•
•
•
try this:
databaseName.Open "Select * from TableUserPass where FieldUser like '" & comboUser.text & "'and FieldPass like '" & textPass.text & "',connection,3,3
//Put this in your command button//
Hi, may i ask what's the connection for and the 3,3 for? i'm having the same problem. im trying to use what u suggested.
thanks!
•
•
Join Date: Feb 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
' Well this is a litle example of how to block an user in a system it depend on the way you want 'to do it, because if you want to block an id who put 3 times a wrong password you have to be 'sure if it is the same id he is trying that`s the reason why y block the user
' textbox after he put the rigth id, why i do it to this way? just to show that you can do everything 'you want but you have to know What do you want to do! so you can mix thing to get a better 'login, 'but that's your job! i hope this help you!
' textbox after he put the rigth id, why i do it to this way? just to show that you can do everything 'you want but you have to know What do you want to do! so you can mix thing to get a better 'login, 'but that's your job! i hope this help you!
vb Syntax (Toggle Plain Text)
' first you need to textbox named TxtUser and TxtPassword ' and a command buttom named CmdOK ' o whatever you want to named! 'and crate the Database on Access, whit the fields user, password, name and state ' and put and user to try, example: hiddenben, 1234, hidden, Active ' make sure is in the Field State to Write 'Active' whitout spaces ' and put the DB in the same Folder as your Program! ' This Works with Access And Dao, (i prefer ADO is better, but the netx time :mrgreen:) ' Here we Declare our Vars
vb Syntax (Toggle Plain Text)
Dim cn As DAO.Database, rs As DAO.Recordset, intent As Integer ----------------------------------------------------------------------------- Private Sub Form_Load() [color=DarkGreen]' we open the database with our Dao var on the form load[/color] Set cn = OpenDatabase(App.Path & "\Examplelogin.Mdb") End Sub ----------------------------------------------------------------------------- Private Sub TxtUser_LostFocus() [color=DarkGreen]' with this recordset we verify is the user is ok! and state is active! if ' not 3 times we just finish the program and nobody is block[/color] Set rs = cn.OpenRecordset("Select * From user Where user='" & Me.TxtUser & "' and state = 'Active'", 2, 3) If rs.EOF = False Then Me.TxtUser.Enabled = False intent = 0 [color=DarkGreen]'we put this in 0 because we going to use again to verify password[/color] rs.Close Me.TxtPassword.SetFocus Else [color=DarkGreen] 'if not we increase then trys and return the focus to the user textbox[/color] MsgBox "Incorrect", vbInformation + vbOKOnly, "Information" intent = intent + 1 rs.Close If intent < 3 Then Me.TxtUser.SetFocus Exit Sub Else MsgBox "Incorrect Please contact the Administrator", _ vbInformation + vbOKOnly, "Information" End End If End If End Sub -------------------------------------------------------------------------------- [color=DarkGreen]' with this recordset we verify is the password is ok! if not 3 times ' we block the user [/color]Private Sub CmdOk_Click() Set rs = cn.OpenRecordset("Select * From user Where user='" & _ Me.TxtUser & "' and password='" & Me.TxtPassword & "'", 2, 3) If rs.EOF = False Then [color=DarkGreen] ' if the user is correct we pass the control to our first Form[/color] MsgBox "Welcome '" & Me.TxtUser & "'", vbInformation + _ vbOKOnly, "Information" Unload Me rs.Close MDIForm1.Show Else [color=DarkGreen] 'if not we increase then trys and return the focus to the ' password textbox[/color] MsgBox "Incorrect", vbInformation + vbOKOnly, "Information" intent = intent + 1 rs.Close If intent < 3 Then Me.TxtPassword.SetFocus Exit Sub Else Call block [color=DarkGreen]'we call the function to block the user[/color] MsgBox "Incorrect Your UserId is blocked Please contact _ the Administrator", vbExclamation + vbOKOnly, "Wrong" End End If End If End Sub ------------------------------------------------------------------------------- [color=DarkGreen]' this is the function that block the user in the Access Database[/color] Sub block() [color=DarkGreen]' a simple RecordSet[/color] Set rs = cn.OpenRecordset("Select * From user Where user='" & Me.TxtUser & "'", 2, 3) rs.Edit rs!State = "Blocked" [color=DarkGreen] 'Update the State of the user on the DB[/color] rs.Update rs.Close End Sub ------------------------------------------------------------------------------
Last edited by WaltP : Feb 21st, 2007 at 2:29 am. Reason: Please use CODE tags -- note the writing on the background of the
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Lost Windows XP user password (Windows NT / 2000 / XP / 2003)
- DCOM got error "Logon failure: unknown user name or bad password (Windows NT / 2000 / XP / 2003)
- Outlook 2000 requires Windows Password to access (Windows NT / 2000 / XP / 2003)
- XP - "Switch User" nonexistent password problem (Windows NT / 2000 / XP / 2003)
- "net user [username [password | *]" (Windows NT / 2000 / XP / 2003)
- Encrypt File using User Supplied Password (VB.NET)
- Windows 2000 Password Expired (Windows NT / 2000 / XP / 2003)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Server's mulitple listening
- Next Thread: VB6.0 and MS AS Access problem



Linear Mode