/// <summary> /// 备份服务器的数据库 /// </summary> private void btnBackup_Click(object sender, EventArgs e) { try { if (textBackupPath.Text.Trim() == "") { MessageHandler.ShowMessageBox("数据库备份路径不能为空,请重新操作。"); return; } DateTime nowTime = BaseSQL.GetServerDateTime(); string fileNameStr = string.Format("{0}-{1}.bak", SystemInfo.ServerDataBaseName, nowTime.ToString("yyyyMMddHHmmss")); string filePathNameStr = string.Format("{0}\\{1}", textBackupPath.Text.Trim(), fileNameStr); if (BaseSQL.BackupDataBase(SystemInfo.ServerDataBaseName, filePathNameStr))//数据库SQL备份,没有进度条 { MessageHandler.ShowMessageBox(string.Format("备份数据库成功,文件名为[{0}]。", fileNameStr)); } //if (BackupDataBase(SystemInfo.ServerDataBaseName, filePathNameStr, progressBarBackup))//引用SQLDMO类备份,有进度条 //{ // MessageHandler.ShowMessageBox(string.Format("备份数据库成功,文件名为[{0}]。", fileNameStr)); //} } catch (Exception ex) { MessageHandler.ShowMessageBox(string.Format("备份数据库失败--{0}。", ex.Message)); } }