Imports System.Data.OleDb
Public Class frmlog
Dim con As New OleDbConnection
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
If ask() = True Then
MessageBox.Show("Success")
Me.Hide()
Form1.Show()
Else
MessageBox.Show("Invalid")
End If
End Sub
Public Function ask()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
con.Open()
Dim da As New OleDbDataAdapter("select * from log", con)
da.Fill(dt)
For Each DataRow In dt.Rows
If UsernameTextBox.Text = DataRow.item(0) And PasswordTextBox.Text = DataRow(1) Then
con.Close()
Return True
End If
Next
con.Close()
Return False
End Function
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
Private Sub frmlog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "provider= microsoft.jet.oledb.4.0;data source = ..\db.mdb"
End Sub
End Class
This code is for a Login Form that is connected to a database which is MS Access 2007 but everytime I enter the correct username and password and click ok, I got an error : The 'microsoft.jet.oledb.4.0' provider is not registered on the local machine.
Please help me, I need the program this week.