Dotnet总结(2)--访问ms sql server 数据库基类--2

// 测试数据库链接
public static bool TestDBConnect(string strDSN)
{
bool bReturn = true;
SqlConnection oSqlConnection = new SqlConnection(strDSN);
int iTmp = oSqlConnection.ConnectionTimeout;
try
{
oSqlConnection.Open();
}
catch
{
bReturn = false;
}
finally
{
oSqlConnection.Close();
oSqlConnection.Dispose();
}
return bReturn;
}

Published At
Categories with Web编程
Tagged with
comments powered by Disqus