code for login and password..using vb6

Closed Thread

Join Date: Dec 2004
Posts: 116
Reputation: stackOverflow is an unknown quantity at this point 
Solved Threads: 0
stackOverflow's Avatar
stackOverflow stackOverflow is offline Offline
Junior Poster

code for login and password..using vb6

 
1
  #1
Feb 24th, 2005
Hi,

Front end Vb6, back end.. access... connection.. ODADB... can someone please help me with the code for login and password.
Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: code for login and password..using vb6

 
1
  #2
Feb 24th, 2005
so, the usernames and passwords are stored in an access database?
Quick reply to this message  
Join Date: Dec 2004
Posts: 116
Reputation: stackOverflow is an unknown quantity at this point 
Solved Threads: 0
stackOverflow's Avatar
stackOverflow stackOverflow is offline Offline
Junior Poster

Re: code for login and password..using vb6

 
0
  #3
Feb 26th, 2005
Originally Posted by Comatose
so, the usernames and passwords are stored in an access database?
yes...they are stored in access
Quick reply to this message  
Join Date: Jan 2005
Posts: 66
Reputation: Kiba Ookami is an unknown quantity at this point 
Solved Threads: 1
Kiba Ookami's Avatar
Kiba Ookami Kiba Ookami is offline Offline
Junior Poster in Training

Re: code for login and password..using vb6

 
0
  #4
Mar 7th, 2005
Ummm I'm probobly no help...but part of the thing could be done...

IF strUserName="____" AND strPassoword="________" THEN
What happens when you do that
ELSE
It dosn't
END IF
Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: code for login and password..using vb6

 
0
  #5
Mar 10th, 2005
how does the access table look, and what are the field names?
Quick reply to this message  
Join Date: Mar 2005
Posts: 71
Reputation: NewVBguy is an unknown quantity at this point 
Solved Threads: 3
NewVBguy NewVBguy is offline Offline
Junior Poster in Training

Re: code for login and password..using vb6

 
0
  #6
Mar 10th, 2005
Originally Posted by sweety***
Hi,

Front end Vb6, back end.. access... connection.. ODADB... can someone please help me with the code for login and password.
Hi,

just to give some inputs:

in your form you need to have 2 txt field:
1. txtlogin
2: txtpwd

then:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub txtpwd_KeyPress(KeyAscii As Integer)
  2. If KeyAscii = vbEnter Then
  3. If Len(Trim(txtlogin)) > 0 And Len(Trim(txtpwd)) > 0 Then
  4. If CheckPwd(txtlogin, txtpwd) = "ok" Then
  5. MsgBox "Password ok"
  6. Else
  7. MsgBox "Wrong password or Login not found."
  8. End If
  9. Else
  10. MsgBox "Login and password should not be blank"
  11. End If
  12. End If
  13. End Sub
  14.  
  15. Private Function CheckPwd(cLogin As String, cPwd As String)
  16. 'in my case i will use dao. you probably using ado just convert it
  17. Dim rs As Recordset, ret As String
  18. Set rs = opendatabase("c:\temp\login.mdb").openrecordset("select * from tbllogin where ucase(trim(logname)) = '" & UCase(Trim(cLogin)) & "'")
  19. If rs.RecordCount <> 0 Then
  20. If UCase(Trim(rs("pword"))) = UCase(Trim(cPwd)) Then
  21. ret = "ok"
  22. Else
  23. ret = "wrong"
  24. End If
  25. Else
  26. ret = "wrong"
  27. End If
  28. rs.Close: CheckPwd = ret
  29. End Function
'This is just to give you an idea. For sure there are lot of ways of doing it...


Newvbguy
Quick reply to this message  
Join Date: Nov 2006
Posts: 1
Reputation: naiJenn is an unknown quantity at this point 
Solved Threads: 0
naiJenn naiJenn is offline Offline
Newbie Poster

Re: code for login and password..using vb6

 
0
  #7
Nov 15th, 2006
Just wanted to thank you for the code - This was incredibly helpful.

I set up a similar situation and thought I'd share my code.

Differences:
  • I have not included a keyPress Sub but did it from a button click instead.
  • I call from the current database instead of a different one.
  • The recordset is exited as soon as possible, and then any conditions not concerning the recordset are administered.
I could have used a function, but this was a quickie. Most likely will update this to include keypress as well as button click in which both subs call a function.

The table accessed (AdminUser) contains a primary key called 'UserID' [text] and a 'Password' field.

My txtBoxes are named txtUser, and txtPassword

Lots of comments - hope it helps anyone.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub cmdMaintenanceSwitchboard_Click()
  2.  
  3. 'check for null password
  4. If IsNull(Trim(txtUser)) Then
  5. MsgBox "User Name required.", vbExclamation
  6. txtUser.SetFocus
  7. Exit Sub
  8. End If
  9.  
  10. 'check for null password
  11. If IsNull(Trim(txtPassword)) Then
  12. MsgBox "Password required.", vbExclamation
  13. txtPassword.SetFocus
  14. Exit Sub
  15. End If
  16.  
  17. 'To use the following code, open the code window for a form.
  18. 'Under the Tools/References menu, enable the "Microsoft DAO 3.6 Object Library"
  19. 'and some may have to disable the "Microsoft ActiveX Data Objects Library"
  20.  
  21. 'declare variables (tempRecordSet becomes an object variable)
  22. Dim tempRecordSet As Recordset, Password As String
  23.  
  24. 'open the AdminUsers table
  25. '(recordset object variables allow access to records and fields in tables and queries.
  26. 'This modified version opens a recordset via a SQL statement to pull the record (if any) where the field matches the txtUser field in the form.
  27. 'Since the field is a primary key, there should only be one record if any matches are found.
  28. Set tempRecordSet = CurrentDb.OpenRecordset("select * from AdminUsers where UCase(trim(UserID)) = '" & UCase(Trim(txtUser)) & "'")
  29.  
  30. 'retrieve the Password field from the AdminUsers table if the UserID matches the txtUser Field
  31. If tempRecordSet.RecordCount <> 0 Then
  32. Password = UCase(Trim(tempRecordSet("Password")))
  33. End If
  34.  
  35. 'close the recordset and release the recordset object variable
  36. tempRecordSet.Close
  37. Set tempRecordSet = Nothing
  38.  
  39. 'check the password
  40. If Password <> UCase(Trim(txtPassword)) Then
  41. MsgBox "Incorrect password", vbExclamation
  42. Else
  43. 'passwords match, allow the user to the maintenance switchboard
  44. MsgBox "Congratulations! Right Password!!!", vbExclamation
  45. End If
  46. txtPassword = Empty
  47. End Sub
Quick reply to this message  
Join Date: Aug 2005
Posts: 15,343
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1460
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: code for login and password..using vb6

 
0
  #8
Nov 15th, 2006
please don't resurrect two year old threads. Thread closed.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC