<%@ Language=VBScript %> <% Option Explicit %> <% Dim StartTime, EndTime StartTime = Timer Dim objCN ' ADO Connection object Dim objRS ' ADO Recordset object Dim strsql ' SQL query string Dim objRS2 ' Another ADO Recordset object Dim objCmd ' ADO Command object Dim RecordsArray, i ' Create a connection object Set objCN = Server.CreateObject("ADODB.Connection") ' Connect to the data source objCN.ConnectionString = "DSN=datasource" objCN.Open ' Create the a recordset object, and initialize it Set objRS = Server.CreateObject("ADODB.RecordSet") With objRS .CursorType = adOpenForwardOnly .LockType = adLockReadOnly .ActiveConnection = objCN .CursorLocation = adUseServer .Source = "SELECT Field1,Field2,Field3,Field4 FROM tblData" End With ' Create the second recordset object, and initialize it Set objRS2 = Server.CreateObject("ADODB.RecordSet") With objRS2 .CursorType = adOpenForwardOnly .LockType = adLockReadOnly .CursorLocation = adUseServer End With ' Create command object Set objCmd = Server.CreateObject("ADODB.Command") With objCmd .ActiveConnection = objCN .CommandType = adCmdText .Prepared = True .CommandText = "SELECT COUNT(*) FROM tblData WHERE Field1=?" End With ' Create unnamed Parameter and append it to Parameters collection objCmd.Parameters.Append _ objCmd.CreateParameter(,adInteger,adParamInput,4) ' Execute the SQL query objRS.Open ' Write out the results using GetRows in a loop Response.write "
"
Do While Not objRS.EOF
	RecordsArray = objRS.GetRows(30)
	
	For i = 0 To UBound(RecordsArray, 2)
		Response.write RecordsArray(0, i)
		Response.write vbTab
		Response.write RecordsArray(1, i)
		Response.write vbTab
		Response.write RecordsArray(2, i)
		Response.write vbTab
		Response.write RecordsArray(3, i)
		Response.write vbTab
		Response.write vbCrLf
		
		' Use prepared Command and Recordset to issue dummy query
		' Set the parameter for this iteration
		objCmd(0) = RecordsArray(0, i)
		' Run the prepared query
		objRS2.Open objCmd
		Response.write "Dummy query result="
		Response.write objRS2(0)
		objRS2.Close
		Response.write vbCrLf
	Next
Loop
Response.write "
" objRS.Close objCN.Close Set objCN = Nothing Set objRS = Nothing Set objRS2 = Nothing Set objCmd = Nothing EndTime = Timer Response.write "

processing took "&(EndTime-StartTime)&" seconds

 " %>