“您的本地计算机上未安装Microsoft.ACE.OLEDB.12.0提供程序"连接到Access数据库时引发异常 [英] "The Microsoft.ACE.OLEDB.12.0 provider is not installed on your local machine" Exception is thrown while connecting to Access database
问题描述
我一直试图将Microsoft数据库文件连接到我的Visual Basic应用程序.
但是,当我尝试使用代码将其连接时,它会运行,但是当我单击该按钮以检查其凭据崩溃时(Visual Studio说它在粗体区域崩溃了)
代码:
Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=P:\POS System\POS System Database.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Login Info WHERE Username = 'user" & txtStaffID.Text & "' AND password = 'user" & txtPassword.Text & "' ", con)
con.Open()
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
If (sdr.Read() = True) Then
'Pass verification and go to main form.
Me.Hide()
Else
MsgBox("Sorry, The Username or Password was incorrect.", MsgBoxStyle.Critical, "Information")
End If
但是当我尝试通过向导连接它时,出现此错误:
您的本地计算机上未安装Microsoft.ACE.OLEDB.12.0提供程序
有人有什么主意吗?
就在昨天才出现此问题. 安装 2007 Office System驱动程序,然后重新启动Visual Studio. /p>
BTW,一种更好的做法是使用ExecuteScalar()
以便在登录表单中找到用户名和密码之间的匹配项:
Dim result As Integer = 0
Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=P:\POS System\POS System Database.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT COUNT(*) FROM Login Info WHERE Username = 'user" & txtStaffID.Text & "' AND password = 'user" & txtPassword.Text & "' ", con)
con.Open()
result = DirectCast(cmd.ExecuteScalar(), Integer)
con.Close()
If result > 0 Then
'Pass verification and go to main form.
Me.Hide()
Else
MsgBox("Sorry, The Username or Password was incorrect.", MsgBoxStyle.Critical, "Information")
End If
I've been trying to connect a Microsoft database file to my Visual Basic application.
But when I try to connect it using code, it runs but as soon as I click the button to check the credentials it crashes (visual studio says it crashes in the bold area)
Code:
Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=P:\POS System\POS System Database.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Login Info WHERE Username = 'user" & txtStaffID.Text & "' AND password = 'user" & txtPassword.Text & "' ", con)
con.Open()
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
If (sdr.Read() = True) Then
'Pass verification and go to main form.
Me.Hide()
Else
MsgBox("Sorry, The Username or Password was incorrect.", MsgBoxStyle.Critical, "Information")
End If
but when I try to connect it through the wizard, i get this error:
The Microsoft.ACE.OLEDB.12.0 provider is not installed on your local machine
Does anyone have any idea?
had that issue just yesterday. install 2007 Office System Driver and restart visual studio.
BTW, its a better practice to use ExecuteScalar()
in order to to find a match between user and password in a login form:
Dim result As Integer = 0
Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=P:\POS System\POS System Database.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT COUNT(*) FROM Login Info WHERE Username = 'user" & txtStaffID.Text & "' AND password = 'user" & txtPassword.Text & "' ", con)
con.Open()
result = DirectCast(cmd.ExecuteScalar(), Integer)
con.Close()
If result > 0 Then
'Pass verification and go to main form.
Me.Hide()
Else
MsgBox("Sorry, The Username or Password was incorrect.", MsgBoxStyle.Critical, "Information")
End If
这篇关于“您的本地计算机上未安装Microsoft.ACE.OLEDB.12.0提供程序"连接到Access数据库时引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!