ASP中使用Set ors=oConn.Execute()時獲取記錄數的方法
更新時間:2010年12月22日 22:24:13 作者:
在ASP中,如果你使用Set ors=oConn.Execute()來創(chuàng)建RecordSet對象,再使用RecordSet.RecordCount獲取記錄數時,你會發(fā)現它的值為-1,這時,我們可以使用GetRows方法來獲取記錄數。
復制代碼 代碼如下:
<%
Dim oConn, ors, aRows
Dim i,j
Set oConn=Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database/newasp.resx")
Set ors=oConn.Execute("Select TOP 5 SoftID,SoftName FROM NC_SoftList")
Response.Write "RecordCount:" & ors.RecordCount & "<br/>" '-1
aRows=oRs.GetRows(-1) 'oRs.Eof=True,aRows(col,row)
Set ors=Nothing
oConn.Close()
Set oConn=Nothing
If IsArray(aRows) Then
Response.Write "RecordCount:" & UBound(aRows,2)+1 & "<br/>"
For i=0 To UBound(aRows,2)
For j=0 To UBound(aRows,1)
Response.Write aRows(j,i)
If j<> UBound(aRows,1) Then Response.Write ","
Next
Response.Write "<br/>"
Next
End If
%>
相關文章
ASP網頁模板的應用: 讓程序和界面分離,讓ASP腳本更清晰,更換界面更容易
ASP網頁模板的應用: 讓程序和界面分離,讓ASP腳本更清晰,更換界面更容易...2007-01-01