Ask Your Question
3

Is it not possible to establish a connection to an Azure SQL database from a console application using SMO? It functions properly in VS2022's debug mode, but a NullReference error occurs when the application is executed.

asked 2022-08-27 11:00:00 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-11-07 02:00:00 +0000

david gravatar image

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.

edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2022-08-27 11:00:00 +0000

Seen: 18 times

Last updated: Nov 07 '22