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:
Ensure that the connection string used in the console application is the same as the one used in VS2022's debug mode.
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.
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.
Verify that the SMO assemblies are installed on the target machine.
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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-08-27 11:00:00 +0000
Seen: 18 times
Last updated: Nov 07 '22
What does the error message "Incorrect syntax near ')'" mean in SQL?
What is the problem with bindValue in QT SQL?
I keep receiving a 404 error while running the application on AWS EC2, can you help me with that?
How do I resolve a 502 error when attempting to call an HTTPS REST API from an HTTP REST API?