A quick test to access the .NET database.

What would be a very quick way to determine if your connection string allows you to connect to the database?

Typically, a connection attempt keeps the user waiting for a long time before notifying that the attempt is still useless.

+4
source share
2 answers

You did not indicate which database you are connecting to. In SQL Server 2005 from .NET, you can specify the connection timeout in the connection string as follows:

server=<server>;database=<database>;uid=<user>;password=<password>;Connect Timeout=3 

This will try to connect to the server, and if it does not do this in three seconds, it will throw a timeout error.

+10
source

Reduce the latency in the connection string and do something trivial.

The wait should be about the same as the wait time.

You still need a second or two.

+2
source

Source: https://habr.com/ru/post/1276331/


All Articles