如何通过Authentication = ActiveDirectoryInteractive从VBA连接到Azure SQL DB? [英] How do I connect to Azure SQL DB from VBA with Authentication = ActiveDirectoryInteractive?

查看:66
本文介绍了如何通过Authentication = ActiveDirectoryInteractive从VBA连接到Azure SQL DB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置cnSQL = New ADODB.Connection'cnSQL.Open"ODBC; DRIVER = SQL Server;身份验证= ActiveDirectoryInteractive;数据库= XXXXX;数据源= XXXX.database.windows.net"

Set cnSQL = New ADODB.Connection 'cnSQL.Open "ODBC;DRIVER=SQL Server; Authentication = ActiveDirectoryInteractive; Database=XXXXX; Data Source=XXXX.database.windows.net"

推荐答案

这应该为您提供所需的东西.

This should give you what you need.

您必须下载用于SQL Server的ODBC驱动程序17,并且根据您的连接类型,您可以更新身份验证选项

You'll have to download the ODBC Driver 17 for SQL Server and depending on your connection type you can update Authentication option

Sub AdoOdbcExample()    
    Dim con As Object    
    Set con = CreateObject("ADODB.Connection") 
    con.Open _
            "Driver={ODBC Driver 17 for SQL Server};" & _
            "Server=tcp:yourserver.database.windows.net,1433;" & _
            "Database=yourdb;" & _
            "Trusted_Connection=no;" & _
            "Authentication=ActiveDirectoryInteractive;" & _
            "UID=youremail;"
    con.Execute "UPDATE Clients SET FirstName='Gord' WHERE ID=5;"    
    con.Close    
    Set con = Nothing   
    'Authentication=ActiveDirectoryIntegrated
    'Authentication=ActiveDirectoryInteractive
    'ActiveDirectoryPassword  

End Sub

这篇关于如何通过Authentication = ActiveDirectoryInteractive从VBA连接到Azure SQL DB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆