Connection to cloud based SQL Server database using VBA

Hi Guys

This is my first post on this forum, so please bear with me if I may not have inadvertently followed the established guidelines.

Not sure if this falls under this category but hopefully does.

I am trying to establish a connection to a cloud based SQL Server database with multi factor authentication. I successfully created a DSN to it and it works when tested manually. However, when I tried to connect to it using VBA code (through Excel (Office 365)) with the DSN or using OLEDB connectivity, it wouldn't connect - always errored out!

Is a connection string available that I can try and to connect to it through Excel VBA.

Best regards

Deepak

Your DSN is likely using the ODBC Driver with MFA, which is notoriously difficult to call directly from VBA/ADO, as it often fails to prompt the user for credentials.

The recommended approach for VBA with MFA is to use the MSOLEDB provider along with the Authentication=ActiveDirectoryInteractive connection string property.