| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 721 人关注过本帖
标题:数据库的备份
只看楼主 加入收藏
in羊羊
Rank: 1
等 级:新手上路
帖 子:144
专家分:0
注 册:2005-4-17
收藏
 问题点数:0 回复次数:5 
数据库的备份
求助一段系统退出时,数据库自动备份的代码,我现在是一点思路都没有.可能我说的不是很具体,希望大家可以给我提供些思路.谢谢大家
搜索更多相关主题的帖子: 数据库 
2005-04-25 11:03
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 
什么数据库?

天津网站建设 http://www./
2005-04-25 19:17
in羊羊
Rank: 1
等 级:新手上路
帖 子:144
专家分:0
注 册:2005-4-17
收藏
得分:0 
sql server2k
2005-04-25 21:54
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 
直接在SQL Server里设置“数据库维护计划”就可以了。

天津网站建设 http://www./
2005-04-26 00:44
in羊羊
Rank: 1
等 级:新手上路
帖 子:144
专家分:0
注 册:2005-4-17
收藏
得分:0 
我是在vb存取数据库时对数据库进行了更新等操作,系统退出时要备份
2005-04-26 10:24
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 

可以用SQL DEMO组件来操作。 我写的一个备份恢复工具:

bZnXdgQQ.rar (8.25 KB) 数据库的备份

源代码如下: Option Explicit

Private Sub Command1_Click() On Error GoTo ErrHandler Dim Srv As SQLDMO.SQLServer Dim Rest As SQLDMO.Restore Dim Bak As SQLDMO.Backup

If Check = False Then Exit Sub Me.MousePointer = vbHourglass If Option2.Value = True Then Set Srv = New SQLDMO.SQLServer Srv.LoginTimeout = 15 Srv.Connect "(local)", txtUserID.Text, txtPassword.Text Set Rest = New SQLDMO.Restore Rest.Action = 0 ' full db restore Rest.Database = txtDBName.Text Rest.Devices = "" Rest.Files = txtBackupFile.Text Rest.ReplaceDatabase = True 'Force restore over existing database Rest.SQLRestore Srv Set Rest = Nothing Set Srv = Nothing MsgBox "Database restore succeed.", vbInformation, "OK" Else Set Srv = New SQLDMO.SQLServer Srv.LoginTimeout = 15 Srv.Connect "(local)", txtUserID.Text, txtPassword.Text Set Bak = New SQLDMO.Backup Bak.Database = txtDBName.Text Bak.Devices = "" Bak.Files = txtBackupFile.Text Bak.SQLBackup Srv Set Bak = Nothing Set Srv = Nothing MsgBox "Database backup succeed.", vbInformation, "OK" End If Me.MousePointer = vbDefault Exit Sub ErrHandler: Me.MousePointer = vbDefault MsgBox "Error:" & Err.Description, vbCritical, "Error" End Sub

Private Function Check() As Boolean Check = False If Trim(txtUserID.Text) = "" Then MsgBox "Please input the DBA user ID!", vbCritical, "Error" txtUserID.SetFocus Exit Function End If If Trim(txtPassword.Text) = "" Then MsgBox "Please input the DBA password!", vbCritical, "Error" txtPassword.SetFocus Exit Function End If If Trim(txtDBName.Text) = "" Then MsgBox "Please input the database name!", vbCritical, "Error" txtDBName.SetFocus Exit Function End If

If Trim(txtBackupFile.Text) = "" Then MsgBox "Please input the backup file path!", vbCritical, "Error" txtBackupFile.SetFocus Exit Function End If Check = True End Function

Private Function GetFileName(FileName As String) As String GetFileName = Mid(FileName, InStrRev(FileName, "\") + 1) End Function

Private Sub Command2_Click() Unload Me End Sub

Private Sub Form_Load() Dim sysPath As String sysPath = IIf(Len(App.Path) = 3, App.Path, App.Path & "\") txtBackupFile.Text = sysPath & "PrintMate.bak" End Sub


天津网站建设 http://www./
2005-04-26 12:52
快速回复:数据库的备份
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022821 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved