从 ASP VBscript 查询 SQL Server 2008 R2 时,我想从结果集中获取记录数:
Conn = "Provider=SQLNCLI10; DataTypeCompatibility=80; Data Source=Source; Initial Catalog=catalog; User ID=id; Password=pw; Network Library=dbmssocn; Encrypt=Yes;"
这将返回正确的记录计数:
consulta = "select 'x' x;"
rs.open consulta, Conexao, 3
Response.Write(rs.RecordCount)
但是当我从临时表中选择时,它会引发错误:
consulta = "select 'x' x into #t; select * from #t; drop table #t;"
rs.open consulta, Conexao, 3
Response.Write(rs.RecordCount)
ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.