日期:2013-08-30  浏览次数:20466 次

// 测试数据库链接
        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;
        }