如下代码请各位大侠帮手如何简化一下,"恢复access数据库备份"命令如下:
'恢复数据库
Dim Result As DialogResult
Result = MessageBox.Show("数据恢复将破坏现有数据库,继续吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim dlg As New OpenFileDialog '定一个新的OpenFileDialog
dlg.Filter= "备份文件|*.mdbc" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim fc As String=dlg.FileName
Dim f As String=fc.TrimEnd("c") '指定的要删除”c”的字符
DecryptFile(fc,f, "fox") '用于解密EncryptFile函数加密后的文件,
DataTables("帐务处理").DataRows.Clear()
DataTables("users").DataRows.Clear()
DataTables("功能分类").DataRows.Clear()
DataTables("单位").DataRows.Clear()
DataTables("归口类型").DataRows.Clear()
DataTables("授权表").DataRows.Clear()
DataTables("归口类型").DataRows.Clear()
DataTables("收支汇总表").DataRows.Clear()
DataTables("文件管理").DataRows.Clear()
DataTables("正常经费收支情况表").DataRows.Clear()
DataTables("水利专户").DataRows.Clear()
DataTables("水库经营性收支表").DataRows.Clear()
DataTables("科股室").DataRows.Clear()
DataTables("项目设置").DataRows.Clear()
DataTables("预算类型").DataRows.Clear()
DataTables("项目设置").DataRows.Clear()
Dim mg As New Merger
mg.SourcePath = f
mg.PassWord="sir"
mg.SourceTableName = "帐务处理"
mg.DataTableName = "帐务处理"
mg.Merge()
Dim mg2 As New Merger
Mg2.SourcePath = f
Mg2.PassWord="sir"
Mg2.SourceTableName = "users"
Mg2.DataTableName = " users"
Mg2.Merge()
Dim mg3 As New Merger
Mg3.SourcePath = f
Mg3.PassWord="sir"
Mg3.SourceTableName = "功能分类"
Mg3.DataTableName = "功能分类"
Mg3.Merge()
Dim mg4 As New Merger
Mg4.SourcePath = f
Mg4.PassWord="sir"
Mg4.SourceTableName = "单位"
Mg4.DataTableName = "单位"
Mg4.Merge()
Dim mg5 As New Merger
Mg5.SourcePath = f
Mg5.PassWord="sir"
Mg5.SourceTableName = "归口类型"
Mg5.DataTableName = "归口类型"
Mg5.Merge()
Dim mg6 As New Merger
Mg6.SourcePath = f
Mg6.PassWord="sir"
Mg6.SourceTableName = "授权表 "
Mg6.DataTableName = "授权表"
Mg6.Merge()
Dim mg7 As New Merger
Mg7.SourcePath = f
Mg7.PassWord="sir"
Mg7.SourceTableName = "收支汇总表"
Mg7.DataTableName = "收支汇总表"
Mg7.Merge()
Dim mg8 As New Merger
Mg8.SourcePath = f
Mg8.PassWord="sir"
Mg8.SourceTableName = "文件管理 "
Mg8.DataTableName = "文件管理"
Mg8.Merge()
Dim mg9 As New Merger
Mg9.SourcePath = f
Mg9.PassWord="sir"
Mg9.SourceTableName = "正常经费收支情况表 "
Mg9.DataTableName = "正常经费收支情况表"
Mg9.Merge()
Dim mg10 As New Merger
Mg10.SourcePath = f
Mg10.PassWord="sir"
Mg10.SourceTableName = "水利专户"
Mg10.DataTableName = "水利专户"
Mg10.Merge()
Dim mg11 As New Merger
Mg11.SourcePath = f
Mg11.PassWord="sir"
Mg11.SourceTableName = "水库经营性收支表"
Mg11.DataTableName = "水库经营性收支表"
Mg11.Merge()
Dim mg12 As New Merger
Mg12.SourcePath = f
Mg12.PassWord="sir"
Mg12.SourceTableName = "科股室 "
Mg12.DataTableName = "科股室"
Mg12.Merge()
Dim mg13 As New Merger
Mg13.SourcePath = f
Mg13.PassWord="sir"
Mg13.SourceTableName = "项目设置"
Mg13.DataTableName = "项目设置"
Mg13.Merge()
Dim mg14 As New Merger
Mg14.SourcePath = f
Mg14.PassWord="sir"
Mg14.SourceTableName = "预算类型 "
Mg14.DataTableName = "预算类型"
Mg14.Merge()
Dim mg15 As New Merger
Mg15.SourcePath = f
Mg15.PassWord="sir"
Mg15.SourceTableName = "预算草案"
Mg15.DataTableName = "预算草案"
Mg15.Merge()
FileSys.DeleteFile(f,2,2) ‘删除f文件
MessageBox.Show("数据导入成功!")
End If
End If