VB6 Login Need Help
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: VB6 Login Need Help

  1. #1
    Join Date
    Feb 2011

    VB6 Login Need Help

    my program has two user accounts - administrator and a guest
    when i login as an administrator then i have the full access on the commands while if i login as a guest then only the basic commands will be availabe. here's my code:

    Private Sub cmdLogin_Click()
    Dim Username As String
    Dim Password As String
    Username = Me.txtUser.Text
    Password = Me.txtPwd.Text

    If Username = adoLog.Recordset("User").Value And Password = adoLog.Recordset("Password") And adoLog.Recordset("UType") = "Administrator" Then
    Unload Me

    ElseIf adoLog.Recordset("UType") = Guest Then
    With frmMain
    .cmdEdit.Enabled = False
    .cmdDelete.Enabled = False
    .cmdAccounts.Enabled = False
    End With
    ElseIf txtUser.Text = "" And txtPwd.Text = "" Then
    MsgBox "Please enter your username and password!", vbOKOnly + vbCritical, "Login"
    MsgBox "Wrong credentials!", vbOKOnly + vbCritical, "Login"
    txtUser.Text = ""
    txtPwd.Text = ""
    End If

    End Sub

    my problem is that when i use the guest account, the messagebox "Wrong credentials" appear and therefor can not login, but if i use the administrator account i can access the system..can anyone help me?

  2. #2
    Join Date
    Feb 2011

    Re: VB6 Login Need Help

    UType = stands for the two user accounts..please i need your help badly

  3. #3
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: VB6 Login Need Help

    It seems you are only checking one record so you will only get one valid login.

    The proper way is to search the database for the user name entered and then check that record if found with the password and access level
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a Codeguru.com survey!

HTML5 Development Center