论文无忧网提供:计算机毕业论文范文|计算机毕业设计|计算机毕业论文
栏目导航 ASP Java Web .NET VB6.0 JAVA VC VF DELPHI PB 计算机网络 计算机科学与技术 PHP 安卓APP 其他 C# 代写论文
当前位置: > 计算机 > VB6.0 >

A400215学生公寓管理系统

数据备份部分在本程序中用到了一个模块,在模块中有一个方法,dobackup。点击备份按钮后开始备份,代码如下:

copyright paper51.com

If txtDestination<> "" Then 内容来自www.paper51.com

DoBackup PathName,txtDestination

内容来自www.paper51.com

MsgBox "备份成功!", , "提示"

http://www.paper51.com

ElseIftxtDestination = "" Then

http://www.paper51.com

MsgBox "Youmust specify a distination for the backup", vbCritical copyright paper51.com

其中DoBackup为模块中已定义的方法,在这里进行调用。 内容来自www.paper51.com

Dobackup实现方法代码如下所示:

内容来自论文无忧网 www.paper51.com

Dim lFileOp  As Long

内容来自论文无忧网 www.paper51.com

Dim lresult  As Long paper51.com

Dim lFlags   As Long

内容来自www.paper51.com

Dim SHFileOp AsSHFILEOPSTRUCT http://www.paper51.com

Dim strSourceDirAs String 内容来自www.paper51.com

DimstrDestinationDir As String paper51.com

Screen.MousePointer= vbHourglass http://www.paper51.com

BackupFolderName =strDestinationPath

内容来自论文无忧网 www.paper51.com

MkDirBackupFolderName & "\Backup - " & Format(Date,"yyyy.mm.dd")

内容来自www.paper51.com

lFileOp = FO_COPY copyright paper51.com

lFlags = lFlagsAnd Not FOF_SILENT copyright paper51.com

lFlags = lFlags OrFOF_NOCONFIRMATION paper51.com

lFlags = lFlags OrFOF_NOCONFIRMMKDIR

内容来自www.paper51.com

lFlags = lFlags OrFOF_FILESONLY

paper51.com

With SHFileOp

paper51.com

    .wFunc = lFileOp

copyright paper51.com

    .pFrom = strSourcePath &vbNullChar

paper51.com

    .pTo = strDestinationPath& "\Backup - " & Format(Date, "yyyy.mm.dd") &vbNullChar 内容来自www.paper51.com

    .fFlags = lFlags

copyright paper51.com

End With

内容来自www.paper51.com

lresult =SHFileOperation(SHFileOp) paper51.com

Screen.MousePointer= vbDefault http://www.paper51.com

frmBackupDba.lblStatus= "Backup Complete" 内容来自论文无忧网 www.paper51.com

在备份分前先要选择一个备份路径,点击…那个按钮开始进行选择,实现方法如下:

copyright paper51.com

Dim strTemp AsString

paper51.com

strTemp =fBrowseForFolder(Me.hwnd, "Select backup path")

内容来自www.paper51.com

If strTemp<> "" Then

paper51.com

    txtDestination = strTemp

内容来自论文无忧网 www.paper51.com

End If http://www.paper51.com

数据恢复界面同上,它的功能主要是在当前数据库遭到破坏后,可以利用它来进行数据恢复,在数据恢复前要选择所要恢复的数据库路径,如下:

内容来自论文无忧网 www.paper51.com

Dim strTemp AsString 内容来自www.paper51.com

strTemp =fBrowseForFolder(Me.hwnd, "Restore From") 内容来自www.paper51.com

If strTemp<> "" Then

paper51.com

    txtSource = strTemp http://www.paper51.com

    dbasize2 = FileLen(txtSource& "\db.MDB")

paper51.com

    lblSelectedDba ="Selected Backup Database is : " & Format((dbasize2 / 1024) /1024, "standard") & "MB."

http://www.paper51.com

    cmdRestore.Enabled = True

内容来自www.paper51.com

End If 内容来自论文无忧网 www.paper51.com

Erro:

内容来自论文无忧网 www.paper51.com

    Select Case err.Number

内容来自论文无忧网 www.paper51.com

       Case 53'File Not Found paper51.com

         lblSelectedDba = "No Backup at this location" copyright paper51.com

         Toolbar2.Enabled = False

http://www.paper51.com

    End Select

http://www.paper51.com

它主要是查看数据库是否存在,如果所恢复的数据不存在,则会提示错误。 copyright paper51.com

数据恢复也用到了一个方法,在模块中也已经定义了该方法DoRestore。数据恢复代码如下: copyright paper51.com

IfMsgBox("Restoring database from location " & txtSource &" will replace existing database files.Do you want to Contunue",vbYesNo) = vbYes Then 内容来自www.paper51.com

DoRestoretxtSource.Text, App.Path 内容来自www.paper51.com

If NoDba = TrueThen

paper51.com

 MsgBox "Database Restored Click Okto Exit Program" 内容来自论文无忧网 www.paper51.com

 frmRestoreDba.Hide

http://www.paper51.com

 Unload frmRestoreDba copyright paper51.com

End If http://www.paper51.com

Else http://www.paper51.com

 lblStatus.Caption = "DatabaseRestore Canceled" paper51.com

End If

内容来自论文无忧网 www.paper51.com

其中DoRestore实现的功能源码如下所示:

copyright paper51.com

DEFSOURCE ="PROVIDER=Microsoft.jet.oledb.4.0;Persist Security Info=False;DataSource="

http://www.paper51.com

DBName ="\db.MDB;Jet OLEDB:Database Password=matrix-se;"

paper51.com

Set Db = NewADODB.Connection

http://www.paper51.com

  Db.Open DEFSOURCE & App.Path &DBName

http://www.paper51.com

Dim lFileOp  As Long copyright paper51.com

Dim lresult  As Long

内容来自论文无忧网 www.paper51.com

Dim lFlags   As Long

http://www.paper51.com

Dim SHFileOp AsSHFILEOPSTRUCT 内容来自论文无忧网 www.paper51.com

Dim strSourceDirAs String copyright paper51.com

DimstrDestinationDir As String http://www.paper51.com

Db.Close copyright paper51.com

Screen.MousePointer= vbHourglass 内容来自www.paper51.com

BackupFolderName =strDestinationPath copyright paper51.com

lFileOp = FO_COPY http://www.paper51.com

lFlags = lFlagsAnd Not FOF_SILENT

内容来自www.paper51.com

lFlags = lFlags OrFOF_NOCONFIRMATION

copyright paper51.com

lFlags = lFlags OrFOF_NOCONFIRMMKDIR

内容来自论文无忧网 www.paper51.com

lFlags = lFlags OrFOF_FILESONLY

内容来自www.paper51.com

With SHFileOp

内容来自论文无忧网 www.paper51.com

    .wFunc = lFileOp paper51.com

    .pFrom = strSourcePath &"\db.MDB" & vbNullChar

paper51.com

    .pTo = strDestinationPath& vbNullChar

paper51.com

    .fFlags = lFlags paper51.com

End With 内容来自论文无忧网 www.paper51.com

lresult =SHFileOperation(SHFileOp)

内容来自www.paper51.com

Set Db = NewADODB.Connection paper51.com

Db.Open DEFSOURCE& App.Path & DBName

paper51.com

Screen.MousePointer= vbDefault

copyright paper51.com

frmRestoreDba.lblStatus= "Restore Complete" paper51.com

说明:本程序中此部分内容参考了网上的同类型代码,对其进行修改后得到此成型作品,从功能上来讲,它已经实现了它所要完成的工作,经过测试已经没有问题,但是实现的源代码,也只有部分掌握。这实属本人精力与能力有限所置。

内容来自www.paper51.com

------分隔线----------------------------
联系方式