//备份数据库 SQLCA.AutoCommit = TRUE //将数据库备份到文件 ls_style = "USE " + as_databasename EXECUTE IMMEDIATE : ls_style; ls_style = "BACKUP DATABASE " + as_databasename + " TO disk = '" + as_path + "' WITH FORMAT, NAME = 'Full Backup'" EXECUTE IMMEDIATE : ls_style; SQLCA.AutoCommit = false
============还原数据库
//还原数据库 //首先连接到MASTER数据库 string ls_ServerName,ls_LogId,ls_LogPass Transaction SQLMASTER ls_ServerName = SQLCA.ServerName ls_LogId = SQLCA.LogId ls_LogPass = SQLCA.LogPass disconnect using sqlca; SQLMASTER = CREATE Transaction SQLMASTER.DBMS = "MSS Microsoft SQL Server 6.x" SQLMASTER.Database = "master" SQLMASTER.ServerName = ls_ServerName SQLMASTER.LogId = ls_LogId SQLMASTER.LogPass = ls_LogPass SQLMASTER.AutoCommit = true connect using SQLMASTER; //通过master数据库用指定还原文件还原指定数据库 ls_style = "USE master" EXECUTE IMMEDIATE : ls_style using SQLMASTER; ls_style = "RESTORE DATABASE " + as_databasename + " FROM disk = '" + as_path + "'" EXECUTE IMMEDIATE : ls_style using SQLMASTER; IF sqlca.SQLCODE = 0 THEN ls_funreturn = '2' else ls_funreturn = SQLMASTER.sqlerrtext END IF //断开连接,还原原来的SQLCA连接 disconnect using SQLMASTER; connect using sqlca;