尝试使用VB脚本从MS-Excel访问Oracle DB

时间:2017-11-13 18:22:24

标签: excel oracle vbscript

我正在尝试使用VB脚本连接到Oracle DB。我还在管理工具上添加了Microsoft ODBC for Oracle。我仍然得到错误 运行时错误' -2147467259(80004005)': [Microsoft] [ODBC驱动程序管理器]未找到数据源名称且未指定默认驱动程序

代码如下:

Sub ora_connection()
    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim query As String
    Set con = New ADODB.Connection
    Set rs = New ADODB.Recordset
    strCon = "Driver = {Microsoft ODBC for Oracle}; " & _
    "CONNECTSTRING=(DESCRIPTION=" & _
    "(ADDRESS=(PROTOCOL=TCP)" & _
    "(HOST= <provided the host as per TNS>)(PORT = 1521))" & _
    "(CONNECT_DATA=(SERVICE_NAME=<Provided the service_name as per the TNS>))); uid=<User id >; pwd=<password>;)"
    con.Open (strCon)
End Sub

0 个答案:

没有答案