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