我用一段VBS去连接到SQL上,运行一个system stored procedure,然后把结果打印出来。
代码如下
strDBServerName = "DBSRV"
ConnectionString = "Provider=sqloledb;" & _
"Data Source=" & strDBServerName & ";" & _
"Initial Catalog=master;" & _
"Integrated Security=SSPI"
err.clear
Set dbCon = CreateObject("ADODB.Connection")
dbCon.Open ConnectionString
sqlstring = "sp_helprotect"
Set vDBSet = CreateObject("ADODB.Recordset")
vDBSet.open sqlstring, dbCon
Do until vDBSet.eof
For j = 0 to vDBSet.Fields.Count - 1
wscript.echo CStr(vDBSet.Fields.item(j))
Next
vDBSet.MoveNext
Loop
总是得到错误
ADODB.Recordset: Operation is
not allowed when the object is closed.
发现只有运行sp_helprotect有问题,其他,比如sp_configure, sp_helpdb, sp_helprole等等都没问题。
另外,还有一个问题,怎么得到recordset每一个field的名字?
什么建议?多谢!
代码如下
strDBServerName = "DBSRV"
ConnectionString = "Provider=sqloledb;" & _
"Data Source=" & strDBServerName & ";" & _
"Initial Catalog=master;" & _
"Integrated Security=SSPI"
err.clear
Set dbCon = CreateObject("ADODB.Connection")
dbCon.Open ConnectionString
sqlstring = "sp_helprotect"
Set vDBSet = CreateObject("ADODB.Recordset")
vDBSet.open sqlstring, dbCon
Do until vDBSet.eof
For j = 0 to vDBSet.Fields.Count - 1
wscript.echo CStr(vDBSet.Fields.item(j))
Next
vDBSet.MoveNext
Loop
总是得到错误
ADODB.Recordset: Operation is
not allowed when the object is closed.
发现只有运行sp_helprotect有问题,其他,比如sp_configure, sp_helpdb, sp_helprole等等都没问题。
另外,还有一个问题,怎么得到recordset每一个field的名字?
什么建议?多谢!