简体   繁体   English

在VBA中将数据从Excel导出到Oracle

[英]Export Data From Excel to Oracle in VBA

GOOD DAY! 美好的一天! I have question on connection from Excel to Oracle. 我对从Excel到Oracle的连接有疑问。 I don't know what is failing!. 我不知道什么是失败的! My program migrates data and generates a log in another table, and the connection from Oracle fails. 我的程序迁移数据并在另一个表中生成日志,并且与Oracle的连接失败。

Does anyone know why? 有人知道为什么吗? It's my first program! 这是我的第一个程序! Thanks!!!!!!!!! 谢谢!!!!!!!!!

Dim Password As String
Dim SQLStr As String
Dim Server_Name As String
Dim User_ID As String
Dim Database_Name As String

Set rs = CreateObject("ADODB.Recordset")
Server_Name = "localhost"
Database_Name = "BDNAME"
User_ID = "ID"
Password = "PSW"

Set Cn = CreateObject("ADODB.Connection")
Cn.Open "Driver={oracle};Server=" & _
    Server_Name & ";Database=" & Database_Name & _
        ";Uid=" & User_ID & ";Pwd=" & Password & ";"
connect = Cn

Driver={oracle}; is wrong. 是错的。

It depends on the driver/provider you have installed on your machine. 这取决于您在计算机上安装的驱动程序/提供程序。 I would recommend to use the Oracle Provider for OLE DB, you can download from ODAC Runtime Downloads 我建议使用Oracle Provider for OLE DB,可以从ODAC Runtime Downloads下载

In this case the connectionString would be 在这种情况下,connectionString将是

Cn.Open "Provider=OraOLEDB.Oracle;Data Source=" & Database_Name & _
    ";User ID=" & User_ID & ";Password=" & Password

If you like to use other drivers, have a look at https://www.connectionstrings.com/oracle/ 如果您想使用其他驱动程序,请查看https://www.connectionstrings.com/oracle/

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

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