Consulting

Results 1 to 2 of 2

Thread: Connection to cloud based SQL Server database using VBA

  1. #1

    Connection to cloud based SQL Server database using VBA

    Hi Guys




    I am trying to establish a connection to a cloud based SQL Server database (Azure database) with multi factor authentication.

    I successfully created a DSN to it and tested it out manually and it works correctly. However, when I tried to connect to it using VBA code (through Excel (Office 365)) with a connection like the one below it doesn't connect, errors out!




    Dim dbConnectStr As String
    
    Dim adoCN As New ADODB.Connection
    dbConnectStr = "Driver={ODBC Driver 17 for SQL Server};Server=tcp:azepermsqlgssp1.database.windows.net,1433;Database=gssp-prd-sdb;Encrypt=yes;TrustServerCertificate=no;Authentication=ActiveDirectoryIntegrated"
    
    With adoCN
        .CommandTimeout = 0: adoCN.ConnectionTimeout = 0
        .CursorLocation = adUseClient
        .Open dbConnectStr
    End With

    But this doesn't work.Is a connection string available that I can try and to connect to it through Excel VBA.




    Best regards

    Deepak

  2. #2
    can you use Power Query to connect?

Posting Permissions

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