简体   繁体   English

ADODB连接-错误:找不到数据源名称,并且未指定默认驱动程序

[英]ADODB Connection - Error: Data source name not found and no default driver specified

I never had problems connecting to Access DBs in the past using ODBC. 过去,使用ODBC连接到Access DB从未遇到问题。 Now I am trying to connect using ADO/OLEDB and I am getting this error (DSNless connection): 现在,我尝试使用ADO / OLEDB进行连接,并且出现此错误(DSNless连接):

System.Runtime.InteropServices.COMException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. System.Runtime.InteropServices.COMException:[Microsoft] [ODBC驱动程序管理器]找不到数据源名称,也未指定默认驱动程序。

I am no longer using ODBC. 我不再使用ODBC。 As I said I am using ADO/OLEDB. 正如我所说的,我正在使用ADO / OLEDB。 Here's my code: 这是我的代码:

var conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\test.mdb";
// I've also tried the one below, same error
// var conString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\\test.mdb";
var con = new ADODB.Connection( conString );
// bombs here
con.Open();

I've looked at almost everything Google and this site has regarding this error with MS Access. 我已经查看了Google几乎所有内容,并且该站点上有关MS Access的此错误。 I've tried changing my projects back to 32-bit (x86). 我尝试将项目改回32位(x86)。 Nothing seems to work. 似乎没有任何作用。

Anyone have any ideas? 有人有想法么?

UPDATE: I need an ADODB connection because I am using ADOX which requires an ADODB connection. 更新:我需要一个ADODB连接,因为我正在使用需要ADODB连接的ADOX。

var cat = new Catalog();
// this line below will bomb for ODBC or OLEDB
cat.ActiveConnection = con;

Try making OLEDB connection. 尝试建立OLEDB连接。 Also please mention the output . 还请提及输出。

Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim connetionString As String
    Dim cnn As OleDbConnection
    connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yourdatabasename.mdb;"
    cnn = New OleDbConnection(connetionString)
    Try
        cnn.Open()
        MsgBox("Connection Open ! ")
        cnn.Close()
    Catch ex As Exception
        MsgBox("Can not open connection ! ")
    End Try
End Sub
End Class

You need to provide the specific Driver Info While making the connection .Follow the Next code . 在建立连接时,您需要提供特定的驱动程序信息。

Imports System.Data.Odbc
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim connetionString As String
    Dim cnn As OdbcConnection
    connetionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=yourdatabasename.mdb;"
    cnn = New OdbcConnection(connetionString)
    Try
        cnn.Open()
        MsgBox("Connection Open ! ")
        cnn.Close()
    Catch ex As Exception
        MsgBox("Can not open connection ! ")
    End Try
End Sub
End Class

You have to install OLEDB drivers which required to make connection: 您必须安装进行连接所需的OLEDB驱动程序:

Connection string: 连接字符串:

<add name="ConnectionString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source d:\\\\test.mdb;Persist Security Info=False;" />

Drivers can install from below link: http://www.microsoft.com/en-in/download/details.aspx?id=13255 驱动程序可以从下面的链接安装: http : //www.microsoft.com/en-in/download/details.aspx?id=13255

I was just wrestling with this problem and I found an odd solution that worked for me: 我只是在努力解决这个问题,却发现了一个对我有用的奇怪解决方案:

        // NOTE: this way doesn't work.  It throws an error:
        //  System.RuntimeInteropServices.COMException (0x80004005): [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified at ADODB.Connection.Open
        //_connection = new Connection(_connectionString);
        //_connection.Open();

        // This way *does* work.
        _connection = new Connection();
        _connection.Open(_connectionString, null, null, 0);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的SQL连接错误Microsoft] [ODBC驱动程序管理器]找不到数据源名称,并且未指定默认驱动程序 - My Sql Connection error Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified “未找到数据源名称且未指定默认驱动程序”用于创建访问连接 - “Data source name not found and no default driver specified” for creating access connection ODBC错误-找不到数据源名称,并且未指定默认驱动程序 - ODBC Error - Data source name not found and no default driver specified “未找到数据源名称且未指定默认驱动程序”错误 - “Data source name not found and no default driver specified” error 未找到数据源名称且未指定默认驱动程序 - Data source name not found and no default driver specified 未找到数据源名称且未指定默认驱动程序 - Data source name not found and no default driver specified 如何摆脱错误:“.net中找不到数据源名称,没有指定默认驱动程序”? - How to get rid of the error: “Data source name not found and no default driver specified” in .net? C# - 未找到数据源名称且未指定默认驱动程序异常错误 - C# - Data source name not found and no default driver specified Exception Error 错误找不到数据源名称,并且在ADO.NET中没有使用Odbc指定默认驱动程序 - Error Data source name not found and no default driver specified with Odbc in ADO.NET 附加信息:错误[IM002] [Microsoft] [ODBC驱动程序管理器]找不到数据源名称,并且未指定默认驱动程序 - Additional information: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM