hi:

Module Module1
    Public objconcetion As New OleDb.OleDbConnection
    Public objcommand As New OleDb.OleDbCommand
    Public Function open_database() As OleDb.OleDbConnection
        Try
            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 & "" 
            cnn.Open()
            Return cnn
        Catch ex As Exception
            MessageBox.Show(Err.Description)
            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
        open_database()
        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
        open_database.Close()
        Try
            If dr1.Read = False Then
                MessageBox.Show("invalid username and password", "try again")
            Else
                frmmenu_admin.Show()
                frmmenu_admin.btnadmin.Enabled = True
            End If
        Catch ex As Exception
            MsgBox(Err.Description)
        End Try
        If open_database.State <> ConnectionState.Closed Then
            open_database.Close()
        End If
    End Sub
End Class

i have a table in access like this
tablelogin
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?
thanks

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.