在OleDb中打开连接

时间:2016-03-02 07:46:19

标签: vb.net database-connection connection-string oledb

我得到一个"未处理的类型' System.Data.OleDB.OleDbException"发生在system.data.dll"错误

 Dim MDBConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Folder\F1\Loader.mdb"
 Dim con As OleDbConnection = New OleDbConnection(MDBConnString)
 Dim cmd As New OledbCommand
 con.Open() 'on this line

1 个答案:

答案 0 :(得分:0)

将数据库文件保存在Access2003中并使用此代码

<connectionStrings>
    <add name="Conn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\YourDatabaseName.mdb;"/>
  </connectionStrings>