Example #1
0
        /// <summary>
        ///  测试连接是否成功
        /// </summary>
        /// <param name="Server"></param>
        /// <param name="DatabasePrefix"></param>
        /// <param name="Uid"></param>
        /// <param name="Pwd"></param>
        /// <param name="DataWind"></param>
        /// <returns></returns>
        public string GetConnection(string Server, string Database, string Uid, string Pwd, bool Authentication)
        {
            string strSysConnection = "";
            if (Authentication)
                strSysConnection = string.Format("server={0};database={1};integrated security=SSPI", Server, Database);
            else
                strSysConnection = string.Format("server={0};database={1};uid={2};pwd={3}", Server, Database, Uid, Pwd);

            try
            {
                ia = DBAccessLayer.DBFactory.GetDBAccess(strSysConnection);
                if (ia.OpenConnection())
                    return strSysConnection;
                else
                    return "";
            }
            catch (Exception ex)
            {
                return "";
            }
            finally
            {
                ia.CloseConnection();
            }
        }
Example #2
0
 /// <summary>
 ///  测试连接是否成功
 /// </summary>
 /// <param name="Server"></param>
 /// <param name="DatabasePrefix"></param>
 /// <param name="Uid"></param>
 /// <param name="Pwd"></param>
 /// <param name="DataWind"></param>
 /// <returns></returns>
 public bool OpenConnection(string connectionString)
 {
     try
     {
         ia = DBAccessLayer.DBFactory.GetDBAccess(connectionString);
         return ia.OpenConnection();
     }
     catch (Exception ex)
     {
         return false;
     }
     finally
     {
         ia.CloseConnection();
     }
 }