예제 #1
0
        /// <summary>
        /// 重新创建数据库
        /// </summary>
        /// <param name="connName"></param>
        public static void RecreateDb(string connName)
        {
            if (string.IsNullOrWhiteSpace(connName))
            {
                throw new ArgumentException("必须指定connName");
            }

            var    dbName  = FindDbNameFromConnection(connName);
            string connStr = ConfigurationManager.ConnectionStrings[connName].ConnectionString;
            var    helper  = new SqlScriptHelper();

            helper.ReCreateDbIfExist(connStr, dbName);
        }
예제 #2
0
        /// <summary>
        /// 检测数据库是否存在
        /// </summary>
        /// <param name="connName"></param>
        /// <returns></returns>
        public static bool CheckDbExist(string connName)
        {
            if (string.IsNullOrWhiteSpace(connName))
            {
                throw new ArgumentException("必须指定connName");
            }

            var    dbName  = FindDbNameFromConnection(connName);
            string connStr = ConfigurationManager.ConnectionStrings[connName].ConnectionString;
            var    helper  = new SqlScriptHelper();
            var    exist   = helper.CheckDbExist(connStr, dbName);

            return(exist.Success);
        }
예제 #3
0
        /// <summary>
        /// 执行数据库的修正
        /// </summary>
        public static void RunFix(string connName)
        {
            if (string.IsNullOrWhiteSpace(connName))
            {
                throw new ArgumentException("必须指定connName");
            }
            var             connStr = DbConfigHelper.FindConnectionString(connName);
            SqlScriptHelper helper  = new SqlScriptHelper();

            foreach (var sql in Sqls.Values)
            {
                helper.RunScript(connStr, sql, null);
            }
        }