pb中的备份数据库和恢复数据库的代码怎么写?

来源:百度知道 编辑:UC知道 时间:2024/05/14 13:47:46
我现在做了个人事管理系统,是用PB+SQL Server2000写的,现在需要实现一个功能:对数据库进行备份和恢复。不知道怎么写?希望哪位好心人能把我帮代码写出来。。非常感谢!!

备份:
integer msg
string ls_bardir,ls_path,ls_date,ls_exesql,ls_dbname

//调用API
//CloseBitmapClient(Handle(this))

msg = messagebox("提示","进行数据库备份吗?",Question!,YesNoCancel!,3)
if msg = 2 then
return 0
elseif msg = 3 then
return 1
else
if m_main.m_系统管理.m_数据库备份.enabled = true and m_main.m_系统管理.m_数据库备份.visible = true then

SetPointer(HourGlass!)
//获取备份的数据库名
ls_dbname = ProfileString(gs_profile,"Database","SQLCA.Database","")
//获取备份路径
ls_bardir = ProfileString(gs_profile,"path","backpath","")
if not FileExists(ls_bardir) then
CreateDirectory(ls_bardir)
end if
ls_bardir = ls_bardir + "\"
ls_date = string(today(),"yyyymmddhhmmss")
SQLCA.AutoCommit = true
//设置备份文件名
ls_path = ls_bardir + ls_dbname + ls_date + ".bak"