<%@ Language=VBScript %> <% Option Explicit %> <% Dim Method, DataSource, ConnectionString, NumberOfConnections ' Set up test case using the DataSource, Method, and NumberOfConnections ' Uncomment one at a time 'DataSource = "ODBC" 'DataSource = "Jet" DataSource = "SQL Server" 'NumberOfConnections = 1 NumberOfConnections = 2 'Method = 1 'Method = 2 'Method = 3 'Method = 4 'Method = 5 'Method = 6 Method = 7 Dim StartTime, EndTime 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 Dim objCN2 ' Start timer StartTime = Timer ' Create a connection object Set objCN = Server.CreateObject("ADODB.Connection") Set objCN2 = Server.CreateObject("ADODB.Connection") ' Connect to the selected data source If DataSource = "ODBC" Then ConnectionString = "DSN=datasource" End If If DataSource = "Jet" Then ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"&_ "Data Source=C:\Inetpub\wwwroot\data\test.mdb;"&_ "Persist Security Info=False" End If If DataSource = "SQL Server" Then ConnectionString = "Provider=SQLOLEDB.1;"&_ "User ID=sa;Data Source=localhost;"&_ "Initial Catalog=sqltest;Password=;" End If ' Initialize and open Connections objCN.ConnectionString = ConnectionString objCN.Open If NumberOfConnections = 2 Then objCN2.ConnectionString = ConnectionString objCN2.Open End If If NumberOfConnections = 1 Then Set objCN2 = objCN End If ' 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 .ActiveConnection = objCN2 .CursorLocation = adUseServer End With ' Create command object Set objCmd = Server.CreateObject("ADODB.Command") With objCmd .ActiveConnection = objCN2 .Prepared = True End With If Method = 6 Then objCmd.CommandType = adCmdText objCmd.CommandText = "SELECT COUNT(*) FROM tblData WHERE Field1=?" End If If Method = 7 Then objCmd.CommandType = adCmdStoredProc objCmd.CommandText = "dummyquery" End If ' Create Parameter object 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

		Response.write "Dummy query result="
		If Method = 1 Then
			strsql = "SELECT COUNT(*) FROM tblData WHERE Field1="&RecordsArray(0, i)
			objRS2.Open strsql
		End If
		If Method = 2 Then
			strsql = "SELECT COUNT(*) FROM tblData WHERE Field1="&RecordsArray(0, i)
			Set objRS2 = objCN2.Execute(strsql)
		End If
		If Method = 3 Then
			strsql = "EXECUTE dummyquery "&RecordsArray(0, i)
			Set objRS2 = objCN.Execute(strsql)
		End If
		If Method = 4 Then
			strsql = "{call dummyquery('"&RecordsArray(0, i)&"')}"
			Set objRS2 = objCN2.Execute(strsql)
		End If
		If Method = 5 Then
			objCN.dummyquery RecordsArray(0, i), objRS2
		End If
		If Method = 6 Or method = 7 Then
			objCmd(0) = RecordsArray(0, i)
			objRS2.Open objCmd
		End If
		Response.write objRS2(0)
		objRS2.Close
		Response.write vbCrLf
		
	Next
Loop
Response.write "
" objRS.Close Set objRS = Nothing Set objRS2 = Nothing Set objCmd = Nothing objCN.Close Set objCN = Nothing If NumberOfConnections = 2 Then objCN2.Close Set objCN2 = Nothing End If EndTime = Timer Response.write "

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

 " %>