Try-Catch SQL Connection

Hi,

i have a SQL Server Connection that is established at the beginning. If no connection is established, an error message appears:

Connect_db: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

I haven’t found a real exception for this. Do you know how I can catch the error with try catch?

You should check for a System Exception, this would be enough.
Just if you want to be precise, read here for exact exceptions:

Thanks for reply. I have tested the three exceptions variants but unfortunately the error is not caught by the try catch function.

So if you dont Try/Catch it, what exception will appear? This is what you are looking for.

Hi @Crusha ,

I hope the below attached xaml file will help you to catch the exception, just try it
SQL.xaml (7.3 KB)

Do you use a specific Activity?

Your exception have i tried. All other exceptions are not catch.

grafik

@Crusha Please check the attached xaml file exception section, so you can able to understand the logic.

Your xaml dont work. The above error is still displayed.:

Connect_db: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)