vba 将 Excel 连接到 Oracle

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3342442/
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-11 11:56:54  来源:igfitidea点击:

Connect Excel to Oracle

oracleexcel-vbavbaexcel

提问by Ramesh

Can we connect from excel (excel-VBA) to oracle(in a remote server) without installing oracle client in the client system... I tried all the options below but it is throwing error as oracle client should be installed.

我们可以从excel(excel-VBA)连接到oracle(在远程服务器中)而不在客户端系统中安装oracle客户端......我尝试了下面的所有选项,但它抛出错误,因为应该安装oracle客户端。

below is the connectionstring i have used

下面是我使用的连接字符串

1)strConnection = "Provider=OraOLEDB.Oracle;Data Source=SourceName;User Id=Username;
                   Password=password;"  
2)strConnection = "Provider=MSDAORA;Data Source=SourceName;UserId=Username;
                    Password=password;"
3)strConnection = "Provider=MSDAORA.1;User ID=Username/password;Data
                   Source=SourceName;Persist Security Info=False"
4)strConnection = "Driver={Microsoft ODBC for Oracle};SERVER=(DESCRIPTION=
                  (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.6)(PORT=1521)
                 )(CONNECT_DATA (SERVICE_NAME=SERVICEName)));uid=Username;
                   pwd=password;Uid=Username;Pwd=password;"  
5)strConnection = "SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.6)
                   (PORT=1521))(CONNECT_DATA =(SERVICE_NAME=SERVICEName)));
                   uid=Username;pwd=password;"

回答by APC

You need some form of client to connect to an Oracle database, local or remote.

您需要某种形式的客户端来连接到本地或远程的 Oracle 数据库。

You have two choices:

你有两个选择:

  1. Install an Oracle SQL*Net client. If your server is Oracle 10g or higher you don't need the full-blown client: you can use the more lightweight Instant Client.
  2. Buy an n-tier ODBC driver which supports generic connectivity. OpenLinkis one, there are others.
  1. 安装 Oracle SQL*Net 客户端。如果您的服务器是 Oracle 10g 或更高版本,则您不需要成熟的客户端:您可以使用更轻量级的 Instant Client
  2. 购买支持通用连接的n层 ODBC 驱动程序。 OpenLink是其中之一,还有其他。


".can we not connect to the oracle database with only the Drivers or providers present in our OS(Windows XP).."

“.我们不能仅使用我们的操作系统(Windows XP)中存在的驱动程序或提供程序连接到 oracle 数据库吗?”

Think of it this way: the ODBC drivers do not connect to the database, they connect to SQLNet. Then SQLNet connects to the database.

可以这样想:ODBC 驱动程序不连接到数据库,它们连接到 SQL Net。然后 SQLNet 连接到数据库。

"what is the difference between Drivers,providers with the client. "

“驱动程序、提供程序与客户端之间有什么区别。”

The Oracle provided drivers are better tuned for Oracle than the ones MS provides, but in this context they are the same: both require the presence of an Oracle client to work.

Oracle 提供的驱动程序比 MS 提供的驱动程序更适合 Oracle,但在这种情况下它们是相同的:两者都需要存在 Oracle 客户端才能工作。