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

A450高校固定资产管理系统论文

4.3.3数据备份:

数据备份是一个数据库软件必不可少的一部分,利用它可以把当前数据库表进行全面的备份,以备以后使用。因为在操作中可能会导致数据遭到破坏,或者是系统的原因使数据库损坏,或者是一些其它的人为原因,这样你可以用此功能把数据恢复到最后一次备份的状态,使损失做到最少,经常备份,操作起来更有安全感。 copyright paper51.com

①数据备份效果图

copyright paper51.com

paper51.com

图4.7数据备份效果图

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

②功能实现 http://www.snowings.com

    界面制作相对程序来说比较简单,用到的是coolbar控件,点击按钮可以选择备份路径。然后点击数据备份即可。

copyright paper51.com

窗体初始化部分代码如下: 内容来自www.snowings.com

Dim cnn1 AsADODB.Connection paper51.com

Dim rstschema AsADODB.Recordset

内容来自www.snowings.com

Dim strcnn AsString 内容来自www.snowings.com

Set cnn1 = NewADODB.Connection http://www.snowings.com

strcnn ="provider=Microsoft.jet.oledb.4.0;" & "data source="& App.Path & "\db.mdb"

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

cnn1.Open strcnn copyright paper51.com

Set rstschema =cnn1.OpenSchema(adSchemaTables)

paper51.com

Do Untilrstschema.EOF 内容来自论文无忧网 www.snowings.com

temp =rstschema!Table_Name http://www.snowings.com

If Left(temp, 1)<> "M" Then

http://www.snowings.com

End If

http://www.snowings.com

rstschema.MoveNext 内容来自www.snowings.com

Loop

copyright paper51.com

cnn1.Close paper51.com

On Error GoTo err paper51.com

PathName =App.Path & "\db.MDB"

copyright paper51.com

dbasize =FileLen(PathName)

http://www.snowings.com

err:

http://www.snowings.com

Exit Sub paper51.com

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

If txtDestination<> "" Then paper51.com

DoBackup PathName,txtDestination

paper51.com

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

内容来自www.snowings.com

ElseIftxtDestination = "" Then

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

MsgBox "Youmust specify a distination for the backup", vbCritical

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

其中DoBackup为模块中已定义的方法,在这里进行调用。

内容来自www.snowings.com

Dobackup实现方法代码如下所示: 内容来自论文无忧网 www.snowings.com

Dim lFileOp  As Long

copyright paper51.com

Dim lresult  As Long http://www.snowings.com

Dim lFlags   As Long

http://www.snowings.com

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

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

DimstrDestinationDir As String

copyright paper51.com

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

BackupFolderName =strDestinationPath paper51.com

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

内容来自www.snowings.com

lFileOp = FO_COPY paper51.com

lFlags = lFlagsAnd Not FOF_SILENT paper51.com

lFlags = lFlags OrFOF_NOCONFIRMATION

copyright paper51.com

lFlags = lFlags OrFOF_NOCONFIRMMKDIR 内容来自论文无忧网 www.snowings.com

lFlags = lFlags OrFOF_FILESONLY http://www.snowings.com

With SHFileOp paper51.com

    .wFunc = lFileOp

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

    .pFrom = strSourcePath &vbNullChar

http://www.snowings.com

    .pTo = strDestinationPath& "\Backup - " & Format(Date, "yyyy.mm.dd") &vbNullChar

内容来自www.snowings.com

    .fFlags = lFlags

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

End With paper51.com

lresult =SHFileOperation(SHFileOp)

http://www.snowings.com

Screen.MousePointer= vbDefault

http://www.snowings.com

frmBackupDba.lblStatus= "Backup Complete"

paper51.com

在备份分前先要选择一个备份路径,点击…那个按钮开始进行选择,实现方法如下: 内容来自www.snowings.com

Dim strTemp AsString

copyright paper51.com

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

内容来自www.snowings.com

If strTemp<> "" Then 内容来自www.snowings.com

    txtDestination = strTemp

paper51.com

End If

内容来自www.snowings.com

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

paper51.com

Dim strTemp AsString

paper51.com

strTemp =fBrowseForFolder(Me.hwnd, "Restore From") paper51.com

If strTemp<> "" Then http://www.snowings.com

    txtSource = strTemp copyright paper51.com

    dbasize2 = FileLen(txtSource& "\db.MDB") 内容来自论文无忧网 www.snowings.com

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

copyright paper51.com

    cmdRestore.Enabled = True 内容来自论文无忧网 www.snowings.com

End If

http://www.snowings.com

Erro:

http://www.snowings.com

    Select Case err.Number 内容来自www.snowings.com

       Case 53'File Not Found 内容来自www.snowings.com

         lblSelectedDba = "No Backup at this location"

paper51.com

         Toolbar2.Enabled = False copyright paper51.com

    End Select 内容来自www.snowings.com

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