"一般性网络错误,请检查网络文档"的错误
请帮忙看看什么问题啊
数据库备份: 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编辑过]