VB中如何备份access?

SBear 2004-09-19 10:22:59
除了filecopy还有什么办法能整个数据库备份?

还有,如何备份某一部分数据?
...全文
129 10 点赞 打赏 收藏 举报
写回复
10 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zcm123 2004-09-20
直接复制mdb文件
  • 打赏
  • 举报
回复
sunmoonrock 2004-09-20
好,顶一下
  • 打赏
  • 举报
回复
SBear 2004-09-20
需要加那些部件?
  • 打赏
  • 举报
回复
SBear 2004-09-20
谢谢
  • 打赏
  • 举报
回复
wumylove1234 2004-09-19
还有?用二进制自已读,自已写.用FSO来操作文件,用我上面的API.
FileCopy是什么?
  • 打赏
  • 举报
回复
SBear 2004-09-19
还是有问题,只能在数据库没打开的情况下才行。
  • 打赏
  • 举报
回复
SBear 2004-09-19
http://community.csdn.net/Expert/topic/3244/3244160.xml?temp=.3823969

已经搞定
  • 打赏
  • 举报
回复
wumylove1234 2004-09-19

Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
  • 打赏
  • 举报
回复
wumylove1234 2004-09-19
Option Explicit

Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdSave_Click()
Select Case SSTab1.Tab
Case 0
If BackupData(txtPath(0).Text) = True Then
MsgBox "备份文件成功!", vbOKOnly, App.Title
Unload Me
Else
MsgBox "背份文件失败!请检查路径和当前的数据连接!", vbOKOnly, App.Title
Exit Sub
End If
Case 1
If RestoreData(txtPath(1).Text) = True Then
MsgBox "恢复文件成功!", vbOKOnly, App.Title
Unload Me
Else
MsgBox "背份文件失败!请检查路径和当前的数据连接!", vbOKOnly, App.Title
Exit Sub
End If
End Select
End Sub

Private Sub cmdSelect_Click(Index As Integer)

ChDir (App.Path)
cdlBrowser.Filter = "备份文件(*.ZYB)|*.ZYB"
cdlBrowser.CancelError = True
On Error GoTo errhandle:
Select Case Index
Case 0
cdlBrowser.DialogTitle = "保存文件到"
cdlBrowser.FileName = "数据备份" & Format(Date, "yyyy-mm-dd")

cdlBrowser.ShowSave
Case 1
cdlBrowser.FileName = ""
cdlBrowser.DialogTitle = "选择文件"
cdlBrowser.ShowOpen
End Select
If Err.Number <> 0 Then
Exit Sub
Else
If SSTab1.Tab = 0 Then
txtPath(0).Text = cdlBrowser.FileName
ElseIf SSTab1.Tab = 1 Then
txtPath(1).Text = cdlBrowser.FileName
End If
End If
errhandle:
Exit Sub
End Sub

Private Function BackupData(z As String) As Boolean
Dim i As Long
i = CopyFile(MyAppPath & "Data\DB.MDB", z, 0)
If i <> 0 Then
BackupData = True
Else
BackupData = False
End If
End Function

Private Function RestoreData(s As String) As Boolean
Dim i As Long
i = CopyFile(s, MyAppPath & "Data\Temp.MDB", 0)
If i <> 0 Then
i = DeleteFile(MyAppPath & "Data\Db.MDB")
If i <> 0 Then
Name MyAppPath & "Data\Temp.MDB" As MyAppPath & "data\Db.mdb"
RestoreData = True
End If
Else
RestoreData = False
End If
End Function

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then SendKeys "{TAB}"
If KeyCode = vbKeyEscape Then Unload Me

End Sub

Private Sub Form_Load()
Set Me.Icon = frmParent.Icon
End Sub
  • 打赏
  • 举报
回复
hcyzs 2004-09-19
使用select * into backuptable in "c:\backup\backup.mdb" from tablename where id=...
  • 打赏
  • 举报
回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2004-09-19 10:22
社区公告
暂无公告