Results 1 to 2 of 2

Thread: Help

  1. #1
    Join Date
    Jul 2014
    Posts
    1

    Unanswered: Help

    Hi im a student still learning about vb and database, need help on my codes on how to separate user and admin logins. Here is my code im so confused right now



    Public Class Form1

    Dim loginerror As String
    Dim logtry As Integer


    Public Function Login()

    Dim DBConn As New ADODB.Connection
    Dim User As New ADODB.Recordset
    Dim Username As String
    Dim userDB As String
    Dim passDB As String


    Dim UserFound As Boolean


    DBConn.Open("Provider = Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source = '" & Application.StartupPath & "\LoginDB.mdb'")

    User.Open("UserTable", DBConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)

    UserFound = False
    Login = False
    Username = "Username = '" & txtUser.Text & "'"



    Do
    User.Find(Username)
    If User.BOF = False And User.EOF = False Then

    userDB = User.Fields("Username").Value.ToString
    passDB = User.Fields("Password").Value.ToString

    If userDB <> txtUser.Text Then
    User.MoveNext()
    Else
    UserFound = True
    If passDB = txtPass.Text Then
    User.Close()
    DBConn.Close()
    Return True
    Else
    loginerror = "Invalid Password"
    User.Close()
    DBConn.Close()
    logtry = logtry + 1
    If logtry >= 3 Then
    MessageBox.Show("error")
    End
    End If
    Return False
    End If
    End If
    Else
    loginerror = "Invalid Username"
    User.Close()
    DBConn.Close()
    logtry = logtry + 1
    If logtry >= 3 Then
    MessageBox.Show("error")
    End
    End If
    Return False
    End If
    Loop Until UserFound = True

    User.Close()
    DBConn.Close()
    Return False


    End Function


    Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
    Dim admin = Me.UserTableTableAdapter1.adminLOG()

    If Login() = True Then
    MessageBox.Show("Welcome")
    Me.Hide()
    Form2.Show()
    Else
    MessageBox.Show(loginerror, " Login Message")
    End If
    End Sub
    End Class

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    why would there be a any difference between a normal user logon and an admin user logon?
    a log on is a logon, unless there are some additional hoops you want to make yopur admin users go through.

    what Id suggest you need is something somewhere that identifies what permissions a user has
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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