如何使用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.