我有一些VB代码看不懂,请高手指教!!!
1.PrivateSubCommand1_Click()''备份数据库OnErrorGoToErrSaveSettingApp.Path,"Settings","Data...
1.Private Sub Command1_Click() ''备份数据库
On Error GoTo Err
SaveSetting App.Path, "Settings", "DatabasePath", Trim(Text1.Text)
mFso.CopyFile App.Path + "\database.mdb", Trim(Text1.Text) & "\" & DateChange(Date) & ".mdb", True
MsgBox "数据库备份成功!", , "提示"
Unload Me
Exit Sub
Err:
MsgBox Err.Description
End Sub
2.Private Sub Command1_Click()
On Error GoTo Err
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
Err:
End Sub
3.Private Sub Command2_Click()
On Error GoTo Err
Dim ss As Integer
If Trim(Text1.Text) = "" Then
MsgBox "请选择数据库!", , "提示"
Exit Sub
End If
ss = MsgBox("真的恢复数据库,原数据将被重写吗?", vbCritical + vbOKCancel, "系统提示")
If ss = 1 Then
CN.Close
Set CN = Nothing
' Kill App.Path + "\database.mdb"
mFso.CopyFile Text1.Text, App.Path + "\database.mdb", True
If CN.State Then CN.Close
CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb;Persist Security Info=False"
CN.Open
MsgBox "恢复成功!", , "提示"
Unload Me
End If
Exit Sub
Err:
MsgBox Err.Description
End
End Sub
谢谢了!麻烦详细解释一下。小妹在此谢谢了!!!!!! 展开
On Error GoTo Err
SaveSetting App.Path, "Settings", "DatabasePath", Trim(Text1.Text)
mFso.CopyFile App.Path + "\database.mdb", Trim(Text1.Text) & "\" & DateChange(Date) & ".mdb", True
MsgBox "数据库备份成功!", , "提示"
Unload Me
Exit Sub
Err:
MsgBox Err.Description
End Sub
2.Private Sub Command1_Click()
On Error GoTo Err
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
Err:
End Sub
3.Private Sub Command2_Click()
On Error GoTo Err
Dim ss As Integer
If Trim(Text1.Text) = "" Then
MsgBox "请选择数据库!", , "提示"
Exit Sub
End If
ss = MsgBox("真的恢复数据库,原数据将被重写吗?", vbCritical + vbOKCancel, "系统提示")
If ss = 1 Then
CN.Close
Set CN = Nothing
' Kill App.Path + "\database.mdb"
mFso.CopyFile Text1.Text, App.Path + "\database.mdb", True
If CN.State Then CN.Close
CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb;Persist Security Info=False"
CN.Open
MsgBox "恢复成功!", , "提示"
Unload Me
End If
Exit Sub
Err:
MsgBox Err.Description
End
End Sub
谢谢了!麻烦详细解释一下。小妹在此谢谢了!!!!!! 展开
1个回答
展开全部
On Error GoTo Err
SaveSetting App.Path, "Settings", "DatabasePath", Trim(Text1.Text)
mFso.CopyFile App.Path + "\database.mdb", Trim(Text1.Text) & "\" & DateChange(Date) & ".mdb", True '选择路径备份数据库!MsgBox "数据库备份成功!", , "提示"
Unload Me '关闭窗口。
Exit Sub
Err:
MsgBox Err.Description '返回在所指定的记录源中能找到的所有字段.
End Sub
2.Private Sub Command1_Click()
On Error GoTo Err
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
Err:
End Sub
3.Private Sub Command2_Click()
On Error GoTo Err
Dim ss As Integer
If Trim(Text1.Text) = "" Then
MsgBox "请选择数据库!", , "提示"
Exit Sub
End If
ss = MsgBox("真的恢复数据库,原数据将被重写吗?", vbCritical + vbOKCancel, "系统提示")
If ss = 1 Then
CN.Close
Set CN = Nothing
' Kill App.Path + "\database.mdb"
mFso.CopyFile Text1.Text, App.Path + "\database.mdb", True
If CN.State Then CN.Close
CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb;Persist Security Info=False"
CN.Open
MsgBox "恢复成功!", , "提示"
Unload Me
End If
Exit Sub
Err:
MsgBox Err.Description
End
End Sub
这个下面的就是反过来写而已!~这个备份太过麻烦,我给你段代码。
先在工程里面加入commdilog 控件
On Error GoTo err
dialog.FileName = ""
dialog.Filter = "MDB files(*.mdb).*.mdb"
dialog.ShowSave
If dialog.FileName <> "" Then
FileCopy App.Path & "\tel.mdb", dialog.FileName
MsgBox "备份数据完成", vbOKOnly, ""
End If
Exit Sub
err:
MsgBox "对不起,备份出错,请关闭所有的子窗口,重新备份.", vbOKOnly, "通知"
On Error GoTo err
dialog.FileName = ""
dialog.Filter = "MDB files(*.mdb).*.mdb"
dialog.ShowSave
If dialog.FileName <> "" Then
FileCopy dialog.FileName, App.Path & "\tel.mdb"
MsgBox "恢复数据完成", vbOKOnly, ""
End If
SaveSetting App.Path, "Settings", "DatabasePath", Trim(Text1.Text)
mFso.CopyFile App.Path + "\database.mdb", Trim(Text1.Text) & "\" & DateChange(Date) & ".mdb", True '选择路径备份数据库!MsgBox "数据库备份成功!", , "提示"
Unload Me '关闭窗口。
Exit Sub
Err:
MsgBox Err.Description '返回在所指定的记录源中能找到的所有字段.
End Sub
2.Private Sub Command1_Click()
On Error GoTo Err
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
Err:
End Sub
3.Private Sub Command2_Click()
On Error GoTo Err
Dim ss As Integer
If Trim(Text1.Text) = "" Then
MsgBox "请选择数据库!", , "提示"
Exit Sub
End If
ss = MsgBox("真的恢复数据库,原数据将被重写吗?", vbCritical + vbOKCancel, "系统提示")
If ss = 1 Then
CN.Close
Set CN = Nothing
' Kill App.Path + "\database.mdb"
mFso.CopyFile Text1.Text, App.Path + "\database.mdb", True
If CN.State Then CN.Close
CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb;Persist Security Info=False"
CN.Open
MsgBox "恢复成功!", , "提示"
Unload Me
End If
Exit Sub
Err:
MsgBox Err.Description
End
End Sub
这个下面的就是反过来写而已!~这个备份太过麻烦,我给你段代码。
先在工程里面加入commdilog 控件
On Error GoTo err
dialog.FileName = ""
dialog.Filter = "MDB files(*.mdb).*.mdb"
dialog.ShowSave
If dialog.FileName <> "" Then
FileCopy App.Path & "\tel.mdb", dialog.FileName
MsgBox "备份数据完成", vbOKOnly, ""
End If
Exit Sub
err:
MsgBox "对不起,备份出错,请关闭所有的子窗口,重新备份.", vbOKOnly, "通知"
On Error GoTo err
dialog.FileName = ""
dialog.Filter = "MDB files(*.mdb).*.mdb"
dialog.ShowSave
If dialog.FileName <> "" Then
FileCopy dialog.FileName, App.Path & "\tel.mdb"
MsgBox "恢复数据完成", vbOKOnly, ""
End If
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询