Imports System.Data.OleDb
Imports System.Windows.Forms


Public Class LogonBeheer
    Shared conLogin As OleDb.OleDbConnection
    Shared drLogin As OleDb.OleDbDataReader
    Shared cmdLogin As OleDb.OleDbCommand
    Shared sqlCom As String

    Shared Function logon(ByVal id As String, ByVal paswoord As String) As Boolean
        Try
            conLogin = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=c:\vb\paswoord.mdb")
            conLogin.Open()
            MessageBox.Show("connectie gemaakt", "Connectie", MessageBoxButtons.OK, MessageBoxIcon.Information)
            sqlCom = "SELECT paswoord From gebruikers WHERE userid =  '" & id & "' "
            cmdLogin = New OleDbCommand(sqlCom, conLogin)

            drLogin = cmdLogin.ExecuteReader()
            While drLogin.Read()

                If paswoord = drLogin.Item("paswoord") Then
                    Return True
                    drLogin.Close()
                    conLogin.Close()
                Else
                    Return False
                End If
            End While
        Catch ex As OleDbException
            MessageBox.Show("Er is een fout gebeurt tijden het werken met de database.", "OleDB fout", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Function

    
End Class

