Consulting

Results 1 to 11 of 11

Thread: Connecting oracle and excel sheet

  1. #1

    Thumbs up Connecting oracle and excel sheet


    Guys, help me :

    How to connect excel and oracle using vba code?

    i have database name, username and password plzzz help me with connection codes...


    awaiting for your reply guys!!!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    I have tried the below code

    Sub connection()
    Dim ProdConnectString As String
    Dim conn As New ADODB.connection
    ProdConnectString = "provider=site address;user id=xxxx;password=yyyyy;data source = aaaaaaaa"
    conn.ConnectionString = ProdConnectString
    conn.CursorLocation = adUseClient
    conn.Open
    End Sub

    But i am getting an error "user-defined type not defined" in the highlited area..
    Plzzz help me to proceed

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You have to set a reference to Microft ActiveX Data Objects.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Can you explain, how to do it???
    plzz

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Go to Tools>References in the VBIDE and select it from the list.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You could even use late-binding

    [vba]

    Sub connection()
    Dim ProdConnectString As String
    Dim conn As Object

    Set conn = CreateObject("ADODB.connection")
    ProdConnectString = "provider=site address;user id=xxxx;password=yyyyy;data source = aaaaaaaa"
    conn.ConnectionString = ProdConnectString
    conn.CursorLocation = adUseClient
    conn.Open
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    I have set a reference to microsft activex data objects..
    But i am getting an error "
    Run time error 3706. Provider can not be found. It may not be pro perly installed"

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Oracle will provide an OLEDB data provider which you need to have installed. Try the Microsoft version, or evene the ODBC connection string.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    Quote Originally Posted by xld
    You could even use late-binding

    [vba]

    Sub connection()
    Dim ProdConnectString As String
    Dim conn As Object

    Set conn = CreateObject("ADODB.connection")
    ProdConnectString = "provider=site address;user id=xxxx;password=yyyyy;data source = aaaaaaaa"
    conn.ConnectionString = ProdConnectString
    conn.CursorLocation = adUseClient
    conn.Open
    End Sub
    [/vba]
    The meaning of Early Binding & Late Binding is dawning slowly on me.

    For Early Binding, the user must have the Objects declared and available in the library. Advantage is: he will get to see all the options available.

    For Late Binding, the above is not necessary. The syntax has to be correct or it will result in some kind of Run Time Error. It has this obvious disadvantage. So how does one take a call on Binding option?
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I don't think that will fix this problem, it can't make a connection, eraly or late, because the data provider is not found.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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