CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2011
    Posts
    4

    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
    frmMain.Show

    ElseIf adoLog.Recordset("UType") = Guest Then
    With frmMain
    .Show
    .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"
    txtUser.SetFocus
    Else
    MsgBox "Wrong credentials!", vbOKOnly + vbCritical, "Login"
    txtUser.Text = ""
    txtPwd.Text = ""
    txtUser.SetFocus
    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
    Posts
    4

    Re: VB6 Login Need Help

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

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    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
  •  





Click Here to Expand Forum to Full Width

Featured