标题:如何在VB中实现数据备份?
取消只看楼主
sgh243
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-4-28
 问题点数:0 回复次数:0 
如何在VB中实现数据备份?

本人用的是记录集,想实现数据备份,但是弄了半天还是出错,但是会成一个.bak的备份文件,出错代码和出错信息如下:请赐教错在哪里?谢谢!
Public WithEvents bkps As SQLDMO.Backup
'数据库备份操作
Private Sub Command1_Click()
Dim oSvr As SQLDMO.SQLServer
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
oSQLServer.LoginSecure = False
oSQLServer.Connect "(local)", "sa", "sa" '连接服务器
Screen.MousePointer = 11
Set bkps = CreateObject("SQLDMO.Backup")
bkps.Database = "学生学籍管理" '指定需备份的数据库
bkps.Action = 0
bkps.Files = "E:\数据备份\学生学籍管理.bak" '指定备份文件
bkps.Initialize = True
ProgressBar1.Value = 0
ProgressBar1.Max = 100
Screen.MousePointer = 0
DoEvents
Err = 0

bkps.SQLBackup (oSQLServer)

Screen.MousePointer = 11
ProgressBar1.Value = 100
DoEvents
Set bkps = Nothing
Screen.MousePointer = 0
MsgBox "数据库备份完成"
End Sub
'显示进度
Private Sub bkps_PercentComplete(ByVal Message As String, ByVal Percent As Long)
ProgressBar1.Value = ProgressBar1.Max * (Percent / 100)
End Sub

出错提示:
实时错误'-2147221499(80040005)
[SQL-DMO]代码异常错误:EXCEPTION_ACCESS_VIOLATION

搜索更多相关主题的帖子: 数据备份 SQL 数据库 服务器 
2006-04-29 15:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-61103-1-1.html




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

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