简体   繁体   English

通过Excel连接到Oracle数据库

[英]Connecting to Oracle Database through Excel

I'm trying to connect to an Oracle Database on our server from an Excel sheet, but am having trouble understanding why. 我正在尝试从Excel工作表连接到服务器上的Oracle数据库,但无法理解原因。

I currently have both 32-bit and 64-bit Oracle 12c installed in different ORACLE_HOME s and have a 32-bit installation of Excel on my 64-bit computer. 我目前在不同的ORACLE_HOME安装 32位和64位Oracle 12c,并且在我的64位计算机上安装了32位Excel。

I'm trying to connect to an Oracle Database in Excel using the New Query wizard. 我正在尝试使用“ 新建查询”向导连接到Excel中的Oracle数据库。

新查询向导

When I click From Oracle Database I get the following error/message. 当我单击来自Oracle数据库时 ,出现以下错误/消息。

错误

I can continue with my current provider, but when I actually try to connect to a database I get this: 我可以继续使用当前的提供程序,但是当我实际上尝试连接到数据库时,我得到了:

错误

What I don't understand is why I'm getting this error when I have both 32-bit and 64-bit versions of Oracle 12c installed on my computer. 我不明白的是为什么在计算机上同时安装32位和64位版本的Oracle 12c时出现此错误。 Both are included on my PATH variable (32-bit first), and I also included a specific ORACLE_HOME and TNS_ADMIN to point to my 32-bit installation since my excel is 32-bit. 两者都包含在我的PATH变量中(第一个32位),并且我还包括一个特定的ORACLE_HOMETNS_ADMIN来指向我的32位安装,因为我的Excel是32位。

I really want the ability to query from the database through Excel, but this problem is confusing me to death. 我真的很希望能够通过Excel从数据库查询,但是这个问题使我感到困惑。

EDIT 编辑

I've also just added the ODBC Driver from my Oracle home's into the ODBC Data Source Administrator Tool. 我还刚刚将Oracle主目录中的ODBC驱动程序添加到ODBC数据源管理员工具中。

在此处输入图片说明

It's currently able to connect from this tool. 目前可以通过此工具进行连接。

在此处输入图片说明

But when I try to connect to going through the ODBC Connection wizard, I know get this: 但是,当我尝试通过ODBC连接向导进行连接时 ,我知道得到以下信息: 在此处输入图片说明

Any Ideas? 有任何想法吗?

How did you install 32bit and 64bit Oracle Client? 您如何安装32位和64位Oracle Client?

Please have a look at this instruction: BadImageFormatException. 请查看以下指令: BadImageFormatException。 This will occur when running in 64 bit mode with the 32 bit Oracle client components installed 在安装了32位Oracle客户端组件的64位模式下运行时,会发生这种情况

Short version: 简洁版本:

Your excel is 32bit and you try to use the 32bit Oracle. 您的excel是32位的,您尝试使用32位的Oracle。 I assume you launch the 64bit version of "ODBC Administrator" - there might be the mismatch. 我假设您启动64位版本的“ ODBC管理器”-可能不匹配。 Or you have a problem in your PATH regarding %ORACLE_HOME% and/or %ORACLE_HOME%\\bin folder 或者您的PATH关于%ORACLE_HOME%和/或%ORACLE_HOME%\\bin文件夹的问题

Long version: 长版:

Your Excel is 32bit, so in general you did the right approach by putting the 32bit Client into PATH and for ORACLE_HOME , you cannot mix 32bit and 64bit assemblies in one process. 您的Excel是32位的,因此通常您将32位的客户端放入PATH进行了正确的选择,对于ORACLE_HOME ,您不能在一个进程中混合使用32位和64位程序集。 Btw, when you follow the instructions above your Windows will manage this automatically. 顺便说一句,当您按照上面的说明进行操作时,Windows将自动对其进行管理。

I assume you installed the Oracle Instant Client. 我假设您安装了Oracle Instant Client。 The default Instant Client does not include neither any ODBC driver nor Oracle Data Provider (ODP.NET, Oracle.DataAccess.Client ) 默认的Instant Client不包含任何ODBC驱动程序或Oracle Data Provider(ODP.NET, Oracle.DataAccess.Client

ODBC ODBC

You may have 2 ODBC drivers, one from Oracle typically called like Oracle in OraClient12_home1 and one from Microsoft called Microsoft ODBC for Oracle (which should be installed by default Windows installation, however it also requires an Oracle Client). 您可能有2个ODBC驱动程序,一个来自Oracle,通常称为OraClient12_home1中的Oracle ,另一个来自Microsoft,称为Microsoft ODBC for Oracle (应在Windows的默认安装中安装,但它也需要一个Oracle Client)。

The ODBC driver from Oracle is available for 32bit and 64bit, the Microsoft driver exits only for 32bit. Oracle的ODBC驱动程序适用于32位和64位,而Microsoft驱动程序仅适用于32位。 You have 2 ODBC Administrators, 32bit (run c:\\Windows\\SysWOW64\\odbcad32.exe ) and 64bit (run c:\\Windows\\System32\\odbcad32.exe ). 您有2位ODBC管理员:32位(运行c:\\Windows\\SysWOW64\\odbcad32.exe )和64位(运行c:\\Windows\\System32\\odbcad32.exe )。 There you should see installed drivers for 32 resp. 在那里,您应该看到已安装的32位驱动程序。 64bit. 64位。

Oracle Data Provider Oracle数据提供程序

For the Data Provider you have similar situation. 对于数据提供者,您有类似的情况。 You have one from Microsoft ( Microsoft .NET Framework Data Provider for Oracle , System.Data.OracleClient ) and from Oracle ( Oracle Data Provider for .NET , Oracle.DataAccess.Client , several versions). 您有一个来自Microsoft( 针对Oracle的Microsoft .NET Framework数据提供程序System.Data.OracleClient )和来自Oracle( 针对.NET的Oracle数据提供程序Oracle.DataAccess.Client ,多个版本)。 Both are available for 32bit and 64bit. 两者均适用于32位和64位。

In principle it does not matter which driver/provider you use to connect to Oracle - just the architecture (ie 32 vs. 64 bit) has to match. 原则上,使用哪种驱动程序/提供程序连接到Oracle都没有关系-只是架构(即32位和64位)必须匹配。 Each driver/provider requires according Oracle Client installation. 每个驱动程序/提供程序都需要根据Oracle Client安装。 All drivers/providers from Microsoft have been deprecated, you should prefer the Oracle ones (as stated in the warning message) Microsoft的所有驱动程序/提供程序已被弃用,您应该首选Oracle驱动程序/驱动程序(如警告消息中所述)

Others 其他

Oracle provides also the ODP.NET, Managed Driver which does not require any further Oracle Client installation and runs on both, 32bit and 64bit. Oracle还提供了ODP.NET托管驱动程序 ,它不需要任何其他Oracle Client安装,并且可以在32位和64位上运行。 However, I don't know whether you can use this in Excel. 但是,我不知道您是否可以在Excel中使用它。

Last but not least, you also have OLE DB provider. 最后但并非最不重要的一点,您还具有OLE DB提供程序。 Again one from Microsoft ( Microsoft OLE DB Provider for Oracle ) and one from Oracle ( Oracle Provider for OLE DB ). 再次来自Microsoft( 针对Oracle的Microsoft OLE DB提供程序 )和来自Oracle( 针对OLE DB的Oracle提供程序 )。 The Microsoft provider exist only for 32bit and has been deprecated. Microsoft提供程序仅适用于32位,并且已弃用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM