none
Could not fetch data from Oracle database RRS feed

  • Question

  • Hi all, I cannot fetch data from oracle db to an excel sheet using vb macro. I am getting below error. Can anybody help me please.

     

    My code is as below:

       Sub OracleConnect()
    Dim rs As ADODB.Recordset, c As New ADODB.Connection, r As Range
    c.ConnectionString = "Driver={Microsoft ODBC for Oracle};CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myHost)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=myDatabasename)));UID=myUserID;PWD=myPassword;"
    c.Open
    rs.Open "select * from table where DATE like "&'%TextBox 1.Text%'&"", c, adOpenStatic, adLockReadOnly
    Set ws = ActiveWorkbook.Sheets("Sheet2")
    Set r = ws.Range("A1")
    r.CopyFromRecordset rs
    rs.Close
    c.Close
    End Sub


    sammy

    Tuesday, January 20, 2015 12:42 PM