+ Reply to Thread
Results 1 to 2 of 2

Excel VBA multiple database connections

Hybrid View

  1. #1
    Registered User
    Join Date
    12-21-2006
    Posts
    36

    Excel VBA multiple database connections

    Is it possible to have two open Oracle db connections in Excel VBA?

    I need to create a query with tables joined from two different servers. I've tried to create two connections like below:

    Dim strCNN As String
    Dim strCNN2 As String
    Dim cnn As New ADODB.Connection
    Dim cnn2 As New ADODB Connection 
    
        strCNN = "Provider=MSDAORA.1"
        strCNN = strCNN & ";Password=password"
        strCNN = strCNN & ";User ID=rpt_user"
        strCNN = strCNN & ";Data Source=abc1"
        strCNN = strCNN & ";Persist Security Info=True"
        
        strCNN2 = "Provider=MSDAORA.1"
        strCNN2 = strCNN2 & ";Password=password"
        strCNN2 = strCNN2 & ";User ID=rpt_user"
        strCNN2 = strCNN2 & ";Data Source=def1"
        strCNN2 = strCNN2 & ";Persist Security Info=True"
        
           
        With cnn
          .ConnectionString = strCNN
          .Open
        End With
        
        With cnn
          .ConnectionString = strCNN2
          .Open
       End With
    
    rst.Open strSQL, cnn, adOpenStatic, adLockReadOnly
    Can't find anything on this online so thinking I have to go another route??

    Thanks,

    Toni
    Last edited by thart21; 07-01-2010 at 07:40 PM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Excel VBA multiple database connections

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1