如何使用C#应用程序备份oracle数据库 [英] How to backup oracle database using C# application

查看:126
本文介绍了如何使用C#应用程序备份oracle数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何使用c#应用程序备份oracle数据库。

我尝试了一些示例,但没有奏效。像这个。我不明白一些线条。请给我一些代码示例。请。谢谢。



我尝试过:



Hi,
how to backup oracle database using c# application.
I trying examples but didnt worked. Like this one. I dont understand some of the lines. Please give me some example of codes . Please. and Thank you .

What I have tried:

private void btnBackupDB_Click(object sender, EventArgs e)
{
    //## Settings
    //Path to store the oracle dump
    string path = @"C:\backup";
    string backupFileName = "mybackup.dmp";
    //your ORACLE_HOME enviroment variable must be setted or you need to set the path here:
    string oracleHome = Environment.GetEnvironmentVariable("ORACLE_HOME");
    string oracleUser = "sys";
    string oraclePassword = "abc";
    string oracleSID = "xe";
    //###

    ProcessStartInfo psi = new ProcessStartInfo();

    //Exp is the tool used to export data.
    //this tool is inside $ORACLE_HOME\bin directory
    psi.FileName = Path.Combine(oracleHome, "bin", "exp");
    psi.RedirectStandardInput = false;
    psi.RedirectStandardOutput = true;
    string dumpFile = Path.Combine(path, backupFileName);
    //The command line is: exp user/password@database file=backupname.dmp [OPTIONS....]
    psi.Arguments = string.Format(oracleUser + "/" + oraclePassword + "@" + oracleSID + " FULL=y FILE=" + dumpFile);
    psi.UseShellExecute = false;

    Process process = Process.Start(psi);
    process.WaitForExit();
    process.Close();
    MessageBox.Show("Database Backup Completed Successfully");
    this.Close();

}

推荐答案

ORACLE_HOME \ bin目录
psi.FileName = Path.Combine( oracleHome,bin,exp);
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
string dumpFile = Path.Combine(path,backupFileName);
//命令行是:exp user / password @ database file = backupname.dmp [OPTIONS ....]
psi.Arguments = string.Format(oracleUser +/+ oraclePassword + @+ oracleSID +FULL = y FILE =+ dumpFile);
psi.UseShellExecute = false;

流程流程= Process.Start(psi);
process.WaitForExit();
process.Close();
MessageBox.Show(数据库备份成功完成);
this.Close();

}
ORACLE_HOME\bin directory psi.FileName = Path.Combine(oracleHome, "bin", "exp"); psi.RedirectStandardInput = false; psi.RedirectStandardOutput = true; string dumpFile = Path.Combine(path, backupFileName); //The command line is: exp user/password@database file=backupname.dmp [OPTIONS....] psi.Arguments = string.Format(oracleUser + "/" + oraclePassword + "@" + oracleSID + " FULL=y FILE=" + dumpFile); psi.UseShellExecute = false; Process process = Process.Start(psi); process.WaitForExit(); process.Close(); MessageBox.Show("Database Backup Completed Successfully"); this.Close(); }


在此处查看答案: c# - 从.net到代码的Oracle数据库备份 - Stack Overflow [ ^ ]

它还有助于运行你的应用程序,或Visual Studio,作为管理员。
See answers here: c# - Backup of Oracle database from .net through code - Stack Overflow[^]
It also helps to run your application, or Visual Studio, as administrator.


这篇关于如何使用C#应用程序备份oracle数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆