question

rosey-IT-developer-1 avatar image
0 Votes"
rosey-IT-developer-1 asked rosey-IT-developer-1 commented

Microsoft Access VBA conversion of .Net connection string to Azure SQL Database

I am looking for the equivalent VBA example for the C# .NET example below that allows connection to a Azure SQL Database using the App Registration method: -

private const string CONNECTION_STRING = "Server=tcp:{AzureSQLServerName}.database.windows.net,1433;Initial Catalog=:{AzureSQLDatabaseName};Persist Security Info=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False";
using (var connection = new SqlConnection(CONNECTION_STRING))
{
connection.AccessToken = access_token;
try
{
connection.Open();
}

The issue in VBA using the "CreateObject("ADODB.Connection")" it does not appear to be able to set any before connection arguments to pass the access token to the connection before opening.

Any assistance on this would be appreciated.

azure-sql-databaseoffice-vba-dev
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @rosey-IT-developer-1, welcome to Microsoft Q&A forum,

Do you want to connect to Azure SQL Database using managed identity tokens through Visual Basic?

0 Votes 0 ·

Yes I have used this article here to obtain the access token https://blogs.aaddevsup.xyz/2021/06/how-to-use-an-access-token-to-connect-to-an-azure-sql-database/

0 Votes 0 ·

0 Answers