vb.net OLEDB 连接无法连接到 Access 2013 数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23641648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:32:57  来源:igfitidea点击:

OLEDB Connection won't connect to Access 2013 database

vb.netoledb

提问by Hectic

I am trying to use the OLEDB connection to load my database to my Visual Basic program. However, I am receiving this error:"Could not find installable ISAM."

我正在尝试使用 OLEDB 连接将我的数据库加载到我的 Visual Basic 程序中。但是,我收到此错误:“找不到可安装的 ISAM。”

I am using Microsoft Access Database 2013. As far as I'm aware, 12.0 is the correct version.

我使用的是 Microsoft Access Database 2013。据我所知,12.0 是正确的版本。

This is my code:

这是我的代码:

    Dim con As New OleDb.OleDbConnection
    Dim databaseprovider As String
    Dim dblocation As String
    databaseprovider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
    dblocation = "Date source = C:\HotelBookingDatabase.accdb"
    con.ConnectionString = databaseprovider & dblocation
    con.Open()
    MsgBox("open")
    con.Close()
    MsgBox("closed")

Edit - I have changed "Data source..." to "Data Source..." and installed 2007 Office System drivers, but that hasn't helped my cause.

编辑 - 我已将“数据源...”更改为“数据源...”并安装了 2007 Office System 驱动程序,但这对我的事业没有帮助。

Edit #2 - Looked at the code above again today. I figured out the problem. Instead of "Data Source", my code has "DATE Source". Oops. Updated code, which works:

编辑 #2 - 今天再次查看上面的代码。我解决了这个问题。我的代码不是“数据源”,而是“日期源”。哎呀。更新的代码,它的工作原理:

        Dim con As New OleDb.OleDbConnection
        Dim dbprovider As String
        Dim dbsource As String
        dbprovider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
        dbsource = "Data Source = C:\HotelBookingDatabase.accdb;"
        con.ConnectionString = dbprovider & dbsource
        con.Open()
        MsgBox("ok")
        con.Close()
        MsgBox("bye")

回答by Hectic

I have sorted out the problem.

我已经解决了问题。

I changed my code to this:

我把我的代码改成这样:

Dim con As New OleDbConnection("Provider=MICROSOFT.ACE.OLEDB.12.0; Data Source=C:\HotelBookingDatabase.accdb")

        con.Open()
        MsgBox("ok")
        con.Close()
        MsgBox("bye")