Azure Connection via VB error

  • Thread starter Thread starter Vasavyaa
  • Start date Start date
V

Vasavyaa

Guest
Here is the code to connect to Azure SQL database using Active Directory but I can't connect to it. Am I missing anything ?I feel Azure AD is different but not sure what is that I am missing.

It works well for AWS where I have hosted my MS SQL but its not working in Azure 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

Continue reading...
 
Back
Top