コード例 #1
0
ファイル: form_manage.aspx.cs プロジェクト: albertsundq/i18n
        /// <summary>
        /// 还原数据库
        /// </summary>
        /// <returns>string</returns>
        private string doRestore()
        {
            string bakname = IRequest.GetFormString("BackUp_File");
            string bakpath = Request.MapPath("~\\App_Data") + "\\" + bakname;

            if (dbtype.ToLower() != "dcsqlite")
            {
                SQLDMO.Restore   oRestore   = new SQLDMO.RestoreClass();
                SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
                try
                {
                    oSQLServer.LoginSecure = false;
                    oSQLServer.Connect(conn, dbuser, dbpwd);
                    oRestore.Action          = SQLDMO.SQLDMO_RESTORE_TYPE.SQLDMORestore_Database;
                    oRestore.Database        = dbname;
                    oRestore.Files           = bakpath;
                    oRestore.FileNumber      = 1;
                    oRestore.ReplaceDatabase = true;
                    oRestore.SQLRestore(oSQLServer);
                    return("还原成功!");
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
                finally
                {
                    oSQLServer.DisConnect();
                }
            }
            else if (dbtype.ToLower() == "dcsqlite")
            {
                try
                {
                    string sourcename = Request.MapPath("~/app_data") + "\\DcmsDataBase.db";
                    File.Copy(bakpath, sourcename, true);
                    return("还原成功!");
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
            return("找不到源文件");
        }
コード例 #2
0
ファイル: form_manage.aspx.cs プロジェクト: albertsundq/i18n
        /// <summary>
        /// 还原数据库
        /// </summary>
        /// <returns>string</returns>
        private string doRestore()
        {
            string bakname = IRequest.GetFormString("BackUp_File");
            string bakpath = Request.MapPath("~\\App_Data") + "\\" + bakname;
            if (dbtype.ToLower() != "dcsqlite")
            {
                SQLDMO.Restore oRestore = new SQLDMO.RestoreClass();
                SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
                try
                {
                    oSQLServer.LoginSecure = false;
                    oSQLServer.Connect(conn, dbuser, dbpwd);
                    oRestore.Action = SQLDMO.SQLDMO_RESTORE_TYPE.SQLDMORestore_Database;
                    oRestore.Database = dbname;
                    oRestore.Files = bakpath;
                    oRestore.FileNumber = 1;
                    oRestore.ReplaceDatabase = true;
                    oRestore.SQLRestore(oSQLServer);
                    return "还原成功!";
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
                finally
                {
                    oSQLServer.DisConnect();
                }

            }
            else if (dbtype.ToLower() == "dcsqlite")
            {
                try
                {
                   string sourcename=Request.MapPath("~/app_data")+"\\DcmsDataBase.db";
                   File.Copy(bakpath, sourcename, true);
                   return "还原成功!";
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
            }
            return "找不到源文件";
        }