成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

當前位置:首頁>>開發編程>>數據庫>>新聞內容
應用程序中oracle數據庫備份和恢復
作者:posted 發布時間:2004-9-4 11:11:12 文章來源:cnblogs

昨天花了一個多小時寫的一個小東西,可能以前有很多人寫過了,不過還是放上來看看

備份,可以實現在應用程序文件夾內生成一個DataBaseBak文件夾,并把dmp文件按照時間來保存在這個文件夾內,我設的精度是分鐘,可以自行更改,異常寫入系統日志:

   string startpath = Application.StartupPath;
   DirectoryInfo di = new DirectoryInfo(startpath+"\\DataBaseBak");
   di.Create();
   string oraPath = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Oracle").GetValue("ORACLE_HOME").ToString();
   System.Diagnostics.Process proc = new System.Diagnostics.Process();
   proc.EnableRaisingEvents = false;
   proc.StartInfo.FileName = oraPath +"\\bin\\EXP.exe";
   proc.StartInfo.Arguments = " username/password@servicename file="+di.FullName+"\\filename"+DateTime.Now.ToString("yyyy-MM-dd-HH-mm")+".dmp owner=username";
   proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
   this.Cursor = Cursors.WaitCursor;
   try
   {
    proc.Start();
    MessageBox.Show("數據庫備份成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
   catch(Exception ee)
   {
    MessageBox.Show("數據庫備份失敗","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
    EventLog newLog=new EventLog();
    newLog.Source = "OracleErr";
    newLog.WriteEntry(ee.Message,System.Diagnostics.EventLogEntryType.Error);
   }
   finally
   {
    proc.Dispose();
   }

   this.Cursor = Cursors.Arrow;

恢復,可以自動定位到DataBaseBak文件夾,然后自行選擇需要的dmp文件,進行恢復,并將異常寫入系統日志:

OpenFileDialog selectDMPDialog = new OpenFileDialog();
   selectDMPDialog.InitialDirectory = Application.StartupPath + "
\\DataBaseBak";
   selectDMPDialog.Filter = "備份文件(*.dmp)|*.dmp";
   if(selectDMPDialog.ShowDialog() == DialogResult.OK)
   {
    string oraPath = Registry.LocalMachine.OpenSubKey("software").OpenSubKey("Oracle").GetValue("ORACLE_HOME").ToString();
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.EnableRaisingEvents = false;
    proc.StartInfo.FileName = oraPath+"
\\bin\\IMP.exe";
    proc.StartInfo.Arguments = "
username/password@servicename file="+selectDMPDialog.InitialDirectory+"\\"+selectDMPDialog.FileName+" fromuser=username";
    proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    this.Cursor = Cursors.WaitCursor;
    try
    {
     proc.Start();
     MessageBox.Show("數據庫導入成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
    }
    catch(Exception ee)
    {
     MessageBox.Show("數據庫備份失敗","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
     EventLog newLog=new EventLog();
     newLog.Source = "OracleErr";
     newLog.WriteEntry(ee.Message,System.Diagnostics.EventLogEntryType.Error);
    }
    finally
    {
     proc.Dispose();
    }
    this.Cursor = Cursors.Arrow;


最新更新
·SQL Server 2005刪除用戶失敗
·SQL Server中刪除重復數據的
·經典SQL語句大全
·SQL Server 2005與ASP.NET/A
·三種查看MySQL數據庫版本的方
·SQL Server 2005 Express 遠
·啟用SQL Server 2005 Expres
·Windows下如何安裝或卸載MyS
·解決MySQL5數據庫連接超時問
·清除SQL Server日志的兩種方
相關信息
畫心
愚愛
偏愛
火苗
白狐
畫沙
犯錯
歌曲
傳奇
稻香
小酒窩
獅子座
小情歌
全是愛
棉花糖
海豚音
我相信
甩蔥歌
這叫愛
shero
走天涯
琉璃月
Nobody
我愛他
套馬桿
愛是你我
最后一次
少女時代
灰色頭像
斷橋殘雪
美了美了
狼的誘惑
我很快樂
星月神話
心痛2009
愛丫愛丫
半城煙沙
旗開得勝
郎的誘惑
愛情買賣
2010等你來
我叫小沈陽
i miss you
姑娘我愛你
我們都一樣
其實很寂寞
我愛雨夜花
變心的玫瑰
犀利哥之歌
你是我的眼
你是我的OK繃
貝多芬的悲傷
哥只是個傳說
丟了幸福的豬
找個人來愛我
要嫁就嫁灰太狼
如果這就是愛情
我們沒有在一起
寂寞在唱什么歌
斯琴高麗的傷心
別在我離開之前離開
不是因為寂寞才想你
愛上你等于愛上了錯
在心里從此永遠有個你
一個人的寂寞兩個人的錯
主站蜘蛛池模板: 左云县| 安龙县| 嵩明县| 大化| 三河市| 康定县| 马鞍山市| 金平| 庆安县| 延长县| 新津县| 新余市| 富民县| 汉川市| 来宾市| 行唐县| 宜昌市| 福海县| 芦溪县| 宜都市| 临桂县| 峨山| 明溪县| 梁平县| 保靖县| 北流市| 迁安市| 南郑县| 稷山县| 克东县| 开原市| 墨玉县| 奉节县| 藁城市| 京山县| 巴林右旗| 宝清县| 德州市| 黄山市| 理塘县| 腾冲县|