Results 1 to 3 of 3

Thread: Access Security with VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    7
    Hi...

    I have been working on a project that uses MS Access as the backend for my database application. I need to have a function that will check whether the logon information (i.e. username, password) is correct. If false, then show logon form again and wait for the correct answer before opening db. I already set a password on the Access db.

    Any feedback will be deeply appreciated.

    Sincerely,
    <U> src="http://www.geocities.com/ogmaciel/vbguy74.swf" quality=high bgcolor=#336699 WIDTH=76.5 HEIGHT=76.5 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></U>
    "Don't let school interfere with your education." Mark Twain

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Do you need/want to use Access security (.mda/.mdw files) or are you planning on writing your own?

  3. #3
    Addicted Member JasonGS's Avatar
    Join Date
    May 2000
    Location
    California
    Posts
    155
    What ive done in the past is have the .MDB reside on a hidden server and share (\\server$\dbshare$\file.mdb) and in the client, a table with usernames and passwords. For a login check, id use something like in the code below...
    Code:
    Public Function LoginValid(Username As String, Password As String) As Integer
        
        ' Assume that adoConn is already opened to the DB file/server
        adoRset.Open "SELECT * FROM dbusers WHERE username = '" & Username & "'", adoConn, adOpenStatic + adOpenForwardOnly, adLockReadOnly
        
        If Not adoRset.EOF Then
            adoRset.MoveFirst
            If Password = adoRset("password") Then
                ' Valid username and password
                LoginValid = 100
            Else
                ' Valid username, password is invalid though
                LoginValid = 50
            End If
        Else
            ' Username is not valid
            LoginValid = 0
        End If
        
    End Function
    
    Private Sub Command1_Click()
        Select Case LoginValid(txtUsername.Text, txtPassword.Text)
            Case 0:    MsgBox "Invalid username you rat bastard!"
            Case 50:   MsgBox "Invalid password for the specified user!"
            Case 100:  MsgBox "You have been succesfully logged in!"
        End Select
    End Sub

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