Consulting

Results 1 to 3 of 3

Thread: Azure Connection via VB error

  1. #1

    Azure Connection via VB error

    ​Sub SQL_Connection()


    Dim con As ADODB.Connection 'to get connection
    Dim rs As ADODB.Recordset ' to get record set
    Dim query As String ' to get query
    Set con = New ADODB.Connection ' to inistate connection
    Set rs = New ADODB.Recordset ' to inisate record set ' rs= reocrd set




    strCon = "Trusted_Connection=False;Encrypt=True; Data Source=servername.database.windows.net,1433; Initial Catalog=datbasename;Integrated Security=SSPI"
    con.Open (strCon)
    If con.State = adStateOpen Then
    MsgBox "Your connected now!"
    SQLStr = "SELECT TOP (10)*FROM xxxxxxxx"
    rs.Open SQLStr, con, adOpenStatic
    With Worksheets("sheet1").Range("a6:z500")
    .ClearContents
    .CopyFromRecordset rs
    End With
    Else
    MsgBox "Sorry. you dont have access bud."
    End If


    rs.Close
    Set rs = Nothing
    con.Close
    Set con = Nothing
    End Sub

  2. #2
    What is your question?
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    There is an error here:

    MsgBox "Your connected now!"
    
    should be

    MsgBox "You're connected now!"
    
    Semper in excretia sumus; solum profundum variat.

Tags for this Thread

Posting Permissions

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