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

當前位置:首頁>>開發編程>>數據庫>>新聞內容
應用程序中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繃
貝多芬的悲傷
哥只是個傳說
丟了幸福的豬
找個人來愛我
要嫁就嫁灰太狼
如果這就是愛情
我們沒有在一起
寂寞在唱什么歌
斯琴高麗的傷心
別在我離開之前離開
不是因為寂寞才想你
愛上你等于愛上了錯
在心里從此永遠有個你
一個人的寂寞兩個人的錯
主站蜘蛛池模板: 山西省| 弥渡县| 青冈县| 黄平县| 宁陵县| 夏津县| 铜梁县| 泸西县| 临夏县| 舟曲县| 德兴市| 鹤壁市| 乌兰县| 北川| 江安县| 天水市| 涿州市| 聂荣县| 根河市| 岳阳市| 慈利县| 日土县| 水富县| 扶余县| 靖西县| 富蕴县| 鄯善县| 泸定县| 电白县| 南城县| 金乡县| 航空| 富民县| 西城区| 宁化县| 获嘉县| 仙居县| 砀山县| 体育| 商洛市| 米易县|