如何用C#实现数据库备份?急!!!

解决方案 »

  1.   

    public bool BackUpDB(string backupName,string backupFile)
    {
    bool bl=true;
    try
    {
    if(this.DataBaseConnention() == true)
    {
    this.m_Command.Connection = this.m_Conn;
    this.m_Command.CommandText=@"BACKUP DATABASE TestDB to disk='"+backupFile+"'"+
    " WITH  NOINIT ,  NOUNLOAD ,  NAME = N'"+backupName+"',  NOSKIP ,  STATS = 10,  NOFORMAT ";
    this.m_Command.CommandType=CommandType.Text;
    this.m_Command.ExecuteNonQuery();
    }
    }
    catch(Exception e)
    {
    bl=false;
    MessageBox.Show(e.Message,"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
    }
    return bl;
    }