Results 1 to 3 of 3

Thread: Connecting Oracle DB

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Posts
    16

    Connecting Oracle DB

    I am trying to connect to an oracle database from Excel VBA. I have oracle ODBC connection to the oracle database: ABC
    The code look like this(but don't work):

    Dim oCn1 As ADODB.Connection
    Dim oRs1 As ADODB.Recordset
    Dim connection1 As String
    Dim szSQL As String

    connection1 = "Provider=MSDAORA.1;" & _
    "Password=PW;" & _
    "User ID=UI;" & _
    "Data Source=ABC"

    Set oCn1 = New ADODB.Connection
    oCn1.Open connection1

    szSQL = "SELECT * FROM Table; "

    Set oRs1 = New ADODB.Recordset
    oRs1.Open szSQL, connection1, adOpenForwardOnly, adLockReadOnly, adCmdText

    When I debug it fails on the oRs1.Open, I get the message: "Identifier is too long", thers something wrong with the connection1 String but I dont know what.
    Does anyone know what might be the problem.

    /Bjso

  2. #2
    Addicted Member
    Join Date
    Aug 2004
    Posts
    176
    u have to write:

    VB Code:
    1. Set oRs1 = New ADODB.Recordset
    2. oRs1.Open szSQL, oCn1, adOpenForwardOnly, adLockReadOnly, adCmdText

    the connection is oCn1 n not the connection string

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Posts
    16
    My misstake, but I still get error message: "Invalid Caracter"
    I think there is someting with the ODBC connection.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width