Dotnet总结(2)--访问ms sql server 数据库基类--2
类别: ASP.NET教程
// 测试数据库链接
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;
}
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;
}
- 上一篇: 如何使用.NET配置文件(一)
- 下一篇: Dotnet总结(3)--打印
-= 资 源 教 程 =-
文 章 搜 索