主题:请大家再进来看下 关于filecopy
请高手帮忙下,就是如何吧数据库备份到那个access文件夹里面去!同时也可以从那个文件夹恢复数据库!请帮忙!
工程1在:E:\服装管理。而数据库的位置是:E:\服装管理\access。而我要做
的就是把数据库备份到那个ACCESS里面去!恢复也是!
现在的问题是:备份数据库的好了,但在恢复的时候提示:文件未找到。。。。。。
:duaixj_zhu@yahoo.cn
谢谢
代码如下:
Dim a As String
Dim itmX, key As String
Private Sub Command1_Click()
On Error GoTo error
Dim path As String
If Right(File1.path, 1) <> "\" Then
path = File1.path & "\"
Else
path = File1.path
End If
'备份数据库
If File1.ListCount <> 0 Then
FileCopy Trim(Label1.Caption), path & Date & "备份卡" & File1.FileName
Do While Me.MousePointer <> 0
frm_copy.Show 1
frm_copy.Label1.Caption = "洁儿,数据正在备份中...."
Loop
Unload frm_copy
Me.MousePointer = 0
MsgBox "数据已备份完毕!"
key = Date & "备份卡" & " & File1.FileName"
Set itmX = ListView1.ListItems.Add(, , key, 1)
Exit Sub
End If
error:
MsgBox Err.Description
End Sub
Private Sub Command2_Click()
If File1.ListCount <> 0 Then
'恢复数据库
FileCopy ListView1.SelectedItem, App.path & "\access\" & File1.FileName
Do While Me.MousePointer <> 0
frm_copy.Show 1
frm_copy.Label1.Caption = "洁儿,数据正在恢复中......"
Loop
Unload frm_copy
Me.MousePointer = 0
MsgBox "数据已恢复完毕!"
Else
MsgBox "请选择要恢复的数据!"
End If
Exit Sub
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub File1_Click()
Label1.Caption = Dir1.path & "\access\" & File1.FileName
End Sub
Private Sub Dir1_Change()
File1.path = Dir1.path
'添加数据备份卡到列表中
ListView1.ListItems.Clear
If File1.ListCount <> 0 Then
a = 0
Do While File1.ListIndex < File1.ListCount - 1
File1.ListIndex = a
key = File1.FileName
Set itmX = ListView1.ListItems.Add(, , key, 1)
a = a + 1
Loop
End If
Label1.Caption = Dir1.path & "\" & File1.FileName
End Sub
Private Sub Form_Load()
Dir1_Change
End Sub
工程1在:E:\服装管理。而数据库的位置是:E:\服装管理\access。而我要做
的就是把数据库备份到那个ACCESS里面去!恢复也是!
现在的问题是:备份数据库的好了,但在恢复的时候提示:文件未找到。。。。。。
:duaixj_zhu@yahoo.cn
谢谢
代码如下:
Dim a As String
Dim itmX, key As String
Private Sub Command1_Click()
On Error GoTo error
Dim path As String
If Right(File1.path, 1) <> "\" Then
path = File1.path & "\"
Else
path = File1.path
End If
'备份数据库
If File1.ListCount <> 0 Then
FileCopy Trim(Label1.Caption), path & Date & "备份卡" & File1.FileName
Do While Me.MousePointer <> 0
frm_copy.Show 1
frm_copy.Label1.Caption = "洁儿,数据正在备份中...."
Loop
Unload frm_copy
Me.MousePointer = 0
MsgBox "数据已备份完毕!"
key = Date & "备份卡" & " & File1.FileName"
Set itmX = ListView1.ListItems.Add(, , key, 1)
Exit Sub
End If
error:
MsgBox Err.Description
End Sub
Private Sub Command2_Click()
If File1.ListCount <> 0 Then
'恢复数据库
FileCopy ListView1.SelectedItem, App.path & "\access\" & File1.FileName
Do While Me.MousePointer <> 0
frm_copy.Show 1
frm_copy.Label1.Caption = "洁儿,数据正在恢复中......"
Loop
Unload frm_copy
Me.MousePointer = 0
MsgBox "数据已恢复完毕!"
Else
MsgBox "请选择要恢复的数据!"
End If
Exit Sub
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub File1_Click()
Label1.Caption = Dir1.path & "\access\" & File1.FileName
End Sub
Private Sub Dir1_Change()
File1.path = Dir1.path
'添加数据备份卡到列表中
ListView1.ListItems.Clear
If File1.ListCount <> 0 Then
a = 0
Do While File1.ListIndex < File1.ListCount - 1
File1.ListIndex = a
key = File1.FileName
Set itmX = ListView1.ListItems.Add(, , key, 1)
a = a + 1
Loop
End If
Label1.Caption = Dir1.path & "\" & File1.FileName
End Sub
Private Sub Form_Load()
Dir1_Change
End Sub