首页 > 编程 > .NET > 正文

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

2024-07-21 02:17:02
字体:
来源:转载
供稿:网友
// 测试数据库链接
        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;
        } 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表