Results 1 to 2 of 2

Excel VBA multiple database connections

Threaded 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.

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