con.open()与MS Access DB出错

时间:2013-05-09 08:08:41

标签: vb.net visual-studio-2010 ms-access-2010

到达con.open()时,我收到错误。

Imports System.Data.OleDb
Public Class Form1
Dim con As OleDbConnection
Dim strCon As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=C:\testDB.accdb"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con = New OleDbConnection(strCon)
con.Open()
MsgBox("con open")
con.Close()
MsgBox("con closed")

End Sub
End Class

1 个答案:

答案 0 :(得分:1)

没有错误,很难说,但可能是权限问题?

右键单击testDB.accdb文件,PropertiesSecurityEditAdd,输入“everyone”,点击Check Names,{{1选中每个人时,勾选Ok复选框,然后再Full Control两次。