Possible en double:
How to check if connection string is valid?Existe-t-il un moyen standard .NET de tester si une chaîne SqlConnection fonctionne?
Actuellement, je fais comme ça:
internal bool CheckConnection()
{
using (SqlConnection testConn = new SqlConnection(this.ConnectionString))
{
try
{
testConn.Open();
}
catch (SqlException)
{
return false;
}
}
return true;
}
est-il une meilleure façon de le faire?
Il s'agit d'un doublon. Je supprimerais si je pouvais. – Crisfole