Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It is definitely possible to establish a connection to an Azure SQL database from a console application using SMO. However, it's difficult to provide solutions for the NullReference error without more information about the code and error message. Here are a few things you can try:

  1. Ensure that the connection string used in the console application is the same as the one used in VS2022's debug mode.

  2. Check if there are any differences in the configuration of the target machine and the development machine, such as firewalls, security settings or .NET framework versions.

  3. Try to catch the exception and log the error message to a file. This will give you more information about the exact cause of the NullReference exception.

  4. Verify that the SMO assemblies are installed on the target machine.

  5. If none of the above solutions work, consider using a different approach, such as using the ADO.NET library to establish a connection to the Azure SQL database.