• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

C++ Builder中,sql server在客户端调用_sqlserver

sqlserver 搞代码 3年前 (2018-06-16) 135次浏览 已收录 0个评论

1.Create a backup database stored procedure in master database.

CREATE PROCEDURE backupdb
  @database varchar(10),
  @directory varchar(100)

http://www.gaodaima.com/35599.htmlC++ Builder中,sql server在客户端调用_sqlserver

AS
  backup database @database
  to [email protected]

2.Get path of SQL Server.

AnsiString __fastcall TFrmDM::GetSqlServerPath(){
  AnsiString result,tmp;
  TADOQuery *Query=new TADOQuery(this);
  Query->Connection=ADOConnection_Master;
  Query->Close();
  Query->SQL->Clear();
  Query->SQL->Add(“select filename from sysdatabases where name=’master'”);
  Query->Open();
  tmp=Query->FieldByName(“filename”)->AsString;
  result=tmp.SubString(1,tmp.Length()-15);
  Query->Free();
  return result;
}

3.Call the backup database stored procedure.

  d=FormatDateTime(“yyyy-mm-dd hh-mm-ss”,FrmDM->GetServerTime());
  try{
     path=FrmDM->GetSqlServerPath()+”backup//”;
     FrmDM->ADOStoredProc1->Close();
     FrmDM->ADOStoredProc1->Connection=FrmDM->ADOConnection_Master;
     FrmDM->ADOStoredProc1->Prepared=true;
     FrmDM->ADOStoredProc1->ProcedureName=”backupdb;1″;
     FrmDM->ADOStoredProc1->Parameters->ParamByName(“@database”)->Value = “db_name_to_backup”;
     FrmDM->ADOStoredProc1->Parameters->ParamByName(“@directory”)->Value =path+”db_name_to_backup”+d;
     FrmDM->ADOStoredProc1->ExecProc();
     Application->MessageBox(“备份完成”,”提示”,MB_OK+MB_ICONINFORMATION);
     this->Close();
   }
   catch(…){
     Application->MessageBox(“备份出错,请重新再来”,”警告”,MB_OK+MB_ICONWARNING);
     return;
   }

欢迎大家阅读《C++ Builder中,sql server在客户端调用_sqlserver,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址