1
我想從一個結果集獲得記錄計數R2從ASP VBscript的查詢SQL Server 2008中時:Recordset.RecordCount不允許
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.
你正在使用什麼提供商? 'SQLOLEDB'或'SQLNCLI10' /'SQLNCLI11'? – 2013-02-19 11:41:51
@Clodoaldo - 爲了測試,我使用SQLOLEDB連接到MSSQL 2008 R2數據庫。我的連接字符串如下所示:ConnectionString =「Provider = SQLOLEDB; Server = ServerName; Database = DBName; UId = UserId; Pwd = Password」 - 希望這會有所幫助。 – sgeddes 2013-02-19 13:26:41