¿Es posible comprobar si existe la conexión a una base de datos SQL antes de abrir la conexión?

Is it possible to check if there is a connection to a SQL database exists before opening a new connection?

preguntado el 02 de febrero de 12 a las 10:02

How can a connection "exist" before you open it? -

2 Respuestas

thats why connection pooling is exists for. he checks it and if not - he re-open it.

also you can check it in the web.config for existing entry,.

Respondido 02 Feb 12, 14:02

The web.config will tell you the definition of a connection, but it won't have anything to say about whether there is an open connection or not. - Jon Egerton

@jon he didnt want to see if the conenction is open or not. he wants to check if exists - Royi Namir

Create a method with try catch block. Try connects and returns true, catch returns false. You could even set a shorter timeout so you aren't waiting 90 seconds.

Respondido 02 Feb 12, 17:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.