Module Module1
    Public objconcetion As New OleDb.OleDbConnection
    Public objcommand As New OleDb.OleDbCommand
    Public Function open_database() As OleDb.OleDbConnection
            Dim route As String
            Dim cnn As New OleDb.OleDbConnection
            route = Application.StartupPath & "\" & "video.accdb" 
            If cnn.State = 1 Then cnn.Close()
            cnn.ConnectionString = "provider=microsoft.ace.oledb.12.0;data source =" & route & "" 
            Return cnn
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
End Module

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        objconexion = open_database()
    End Sub

    Private Sub btnokay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnokay.Click
        Dim level As OleDb.OleDbCommand
        Dim connection = "SELECT * FROM tablelogin WHERE username = '" & txtusername.Text & "' AND password = '" & txtPassword.Text & "'"
        Dim cmd As OleDb.OleDbCommand
        cmd = New OleDb.OleDbCommand(connection, open_database)
        Dim dr As OleDb.OleDbDataReader = cmd.ExecuteReader
            If dr1.Read = False Then
                MessageBox.Show("invalid username and password", "try again")
                frmmenu_admin.btnadmin.Enabled = True
            End If
        Catch ex As Exception
        End Try
        If open_database.State <> ConnectionState.Closed Then
        End If
    End Sub
End Class

i have a table in access like this
username password level
admin ******** -1 **
visitor ******** 0

** admin
this code need to verify the level of login, i mean if the user is admin then proceed to the next form with privileges but if is a visitor then proceed to the next form but without privileges. what is the code or line to do that?

If your app is running on a network I would say use the Active Directory to validate there login and assign security level but the groups in which they belong too. However you seem to be creating your own login system where the info is held in the database itself. So essientially you connecting to the db already for validation & security levels. So by that, it is your own design how you want to go about creating restrictions.

This article has been dead for over six months. Start a new discussion instead.