VB如何实现数据库备份?急请各位高手请教

fernery 2002-04-27 02:31:57
VB前台,ACCESS为后台,如何实现数据库备份,且生成bak文件,最好能给出原代码
...全文
18 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yzfx 2002-05-14
其实直接copy file是最简便的,但你可以把数据库的资料读出来,另外写成一个纯文本文件也可以,这样更有特色啦。
回复
ivt 2002-04-27
TO:
阿甘

数据库还原呢
回复
sonicdater 2002-04-27
http://www.csdn.net/expert/topic/679/679972.xml?temp=.7837335
回复
gump2000 2002-04-27
Private Sub cmdOut_Click()
CDialog.DialogTitle = "请输入巡更备份文件名"
CDialog.Filter = "巡更备份文件(*.XGB)|*.XGB"
CDialog.FilterIndex = 1
CDialog.InitDir = "c:\"
CDialog.Flags = cdlOFNHideReadOnly
CDialog.Filename = txtOut.Text
CDialog.ShowSave
txtOut.Text = CDialog.Filename
End Sub


''''''''''''''''''''''''''''''''''''''''''''''''''
'导出文件
If txtOut.Text = "" Then
MsgBox "请输入备份文件名!", vbExclamation, "提示"
Exit Sub
End If
If FileExists(txtOut.Text) Then
If MsgBox(txtOut.Text & "已经存在,是否要覆盖?", vbQuestion + vbYesNo, "提示") = vbNo Then Exit Sub
On Error GoTo out_err
Kill txtOut.Text
End If
BACKCnn.Close
FileCopy BACKDATABASE, txtOut.Text
If BACKCnn.State = adStateClosed Then BACKCnn.Open BackUpCnnString
MsgBox "备份文件导出成功!", vbExclamation, "提示"
Unload Me
Exit Sub
out_err:
MsgBox "备份文件导出错误!错误代码:" & vbCrLf & Error(Err), vbCritical, "错误"
If BACKCnn.State = adStateClosed Then BACKCnn.Open BackUpCnnString
Exit Sub


这个是我的例子代码
我是先关闭连接再backup,假如您不想关闭,可以使用
我上面指出的方法
回复
gump2000 2002-04-27
用FileCopy吧
假如正在使用您可以使用
FileSystemObject对象的CopyFile或者
API函数
Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long


Declare Function CopyFileEx Lib "kernel32.dll" Alias "CopyFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As Long, lpData As Any, ByRef pbCancel As Long, ByVal dwCopyFlags As Long) As Long

回复
发动态
发帖子

1180

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
社区公告
暂无公告