| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 956 人关注过本帖
标题:求助:在恢复数据库备份是出错
取消只看楼主 加入收藏
ruijian1227
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2005-4-22
收藏
 问题点数:0 回复次数:2 
求助:在恢复数据库备份是出错
在用VB做SqlServer2000数据库恢复的时候总出现

"一般性网络错误,请检查网络文档"的错误

请帮忙看看什么问题啊
搜索更多相关主题的帖子: 数据库 网络 文档 检查 
2005-04-22 14:23
ruijian1227
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2005-4-22
收藏
得分:0 
多谢版主了,已经解决了
2005-05-03 23:16
ruijian1227
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2005-4-22
收藏
得分:0 

数据库备份: Public Function BackupAll(ByVal strSql As String) As String On Error GoTo strErrmag CnNew.Execute strSql addFlag = True Exit Function strErrmag: addFlag = False End End Function 数据库恢复: Public Function fRestoreDatabase_a(ByVal sBackUpfileName$ _ , ByVal sDataBaseName$ _ , Optional ByVal sDataBasePath$ = "" _ , Optional ByVal sBackupNumber& = 1 _ , Optional ByVal sReplaceExist As Boolean = False _ ) As String Dim iDb As ADODB.Connection, iRe As ADODB.Recordset Dim iConcStr$, iSql$, iReturn$, iI& On Error GoTo lbErr Dim username As String Dim userpsw As String Dim dbname As String Dim hostname As String

Dim filename

filename = FreeFile Open "c:\dbconnect.ini" For Input As filename Input #filename, username, userpsw, dbname, hostname Set iDb = New ADODB.Connection Set iRe = New ADODB.Recordset iConcStr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;UserID = sa ; Password = " & userpsw & " ;Data Source= " & hostname iDb.Open iConcStr If sDataBasePath = "" Then iSql = "select filename from master..sysfiles" iRe.Open iSql, iDb, adOpenKeyset, adLockReadOnly iSql = iRe(0) iRe.Close sDataBasePath = Left(iSql, InStrRev(iSql, "\")) End If If sReplaceExist = False Then iSql = "select 1 from master..sysdatabases where name='" & sDataBaseName & "'" iRe.Open iSql, iDb, adOpenKeyset, adLockReadOnly If iRe.EOF = False Then iReturn = "Êý¾Ý¿âÒѾ­´æÔÚ!" iRe.Close GoTo lbExit End If iRe.Close End If iSql = "select spid from master..sysprocesses where dbid=db_id('" & sDataBaseName & "')" iRe.Open iSql, iDb, adOpenKeyset, adLockReadOnly While iRe.EOF = False iSql = "kill " & iRe(0) iDb.Execute iSql iRe.MoveNext Wend iRe.Close iSql = "restore filelistonly from disk='" & sBackUpfileName & "'" & vbCrLf & _ "with file=" & sBackupNumber iRe.Open iSql, iDb, adOpenKeyset, adLockReadOnly iSql = "restore database [" & sDataBaseName & "]" & vbCrLf & _ "from disk='" & sBackUpfileName & "'" & vbCrLf & _ "with file=" & sBackupNumber & vbCrLf With iRe While Not .EOF iReturn = iRe("PhysicalName") iI = InStrRev(iReturn, ".") iReturn = IIf(iI = 0, "", Mid(iReturn, iI)) & "'" iSql = iSql & ",move '" & iRe("LogicalName") & _ "' to '" & sDataBasePath & sDataBaseName & iReturn & vbCrLf .MoveNext Wend .Close End With iSql = iSql & IIf(sReplaceExist, ",replace", "") iDb.Execute iSql iReturn = "" GoTo lbExit lbErr: iReturn = Error lbExit: fRestoreDatabase_a = iReturn End Function 这是从网上下载的源码,修改之后可以了。原来出现错误是因为用了数据库之后没有把进程close了,造成连接的进程过多,连接进程过多之后SqlServer本身就会将它们关闭掉,所以就连不上了。

[此贴子已经被作者于2005-5-17 12:37:12编辑过]

2005-05-17 12:35
快速回复:求助:在恢复数据库备份是出错
数据加载中...
 
   



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

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