ACCESS数据库自动备份怎么实现?大神们帮帮忙

ACCESS数据库自动备份怎么实现?大神们帮帮忙,第1张

用VB编写自动备份文件程序 -------------------------------------- Public Sub BackupFile(Filename As String, Drive As String, Folder As String) Dim Fso As New FileSystemObject '创建 FSO 对象实例 Dim Dest_path As String, Counter As Long Dim StrDay As String, StrMonth As String, NewFilename As String Counter = 0 Do While Counter < 6 '如果驱动器没准备好,继续检测。共检测 6 秒 Counter = Counter + 1 Call Waitfor(1) '间隔 1 秒 If FsoDrives(Drive)IsReady = True Then Exit Do End If Loop If FsoDrives(Drive)IsReady = False Then '6 秒后目标盘仍未准备就绪,退出 MsgBox " 目标驱动器 " & Drive & " 没有准备好! ", vbCritical Exit Sub End If If FsoGetDrive(Drive)FreeSpace < FsoGetFile(Filename)Size Then MsgBox "目标驱动器空间太小!", vbCritical '目标驱动器空间不够,退出 Exit Sub End If If Right(Drive, 1) <> ":" Then Drive = Drive & ":" End If If Left(Folder, 1) <> "\" Then Folder = "\" & Folder End If If Right(Folder, 1) <> "\" Then Folder = Folder & "\" End If If Day(Date) < 10 Then StrDay = "0" & Day(Date) Else StrDay = Day(Date) End If If Month(Date) < 10 Then StrMonth = "0" & Month(Date) Else StrMonth = Month(Date) End If 'FsoFileExists () NewFilename = "newfilename" Dest_path = Drive & Folder If Not FsoFolderExists(Dest_path) Then '如果目标文件夹不存在,创建之 FsoCreateFolder Dest_path End If FsoCopyFile Filename, Dest_path & NewFilename, True '拷贝,直接覆盖同名文件 Set Fso = Nothing End Sub Private Sub Waitfor(Delay As Single) '延时过程,Delay 单位约为 1 秒 Dim StartTime As Single StartTime = Timer Do Until (Timer - StartTime) > Delay Loop End Sub Private Sub Form_Load() BackupFile "filename", "d:", "filebackupdir" End End Sub

添加一个timer控件,多长时间做一次自己设置,hour(time)=18(设置每天在18点是进行备份,如果要没星期一就改为week(date),自己设置),语法:
FileCopy
source,
destination
例子:
Private
Sub
Timer1_Timer()
If
hour(Time)=18
Then
FileCopy
"D:\Base\db1mdb","E:\CopyBase"
'将D:\Base\里的db1mdb数据库拷贝到E:\CopyBase里。
End
If
End
Sub

VB工程引用的某个文件丢失。vb组态软件的安装包里面包含很多个文件,工程引用的某个文件丢失,会引起其他莫名其妙的错误,包括没有库。VisualBasic(简称VB)是Microsoft公司开发的一种通用的基于对象的程序设计语言,为结构化的、模块化的、面向对象的、包含协助开发环境的事件驱动为机制的可视化程序设计语言,是一种可用于微软自家产品开发的语言。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/13256282.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-06-27
下一篇 2023-06-27

发表评论

登录后才能评论

评论列表(0条)

保存