Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Re: Records in Selection Question


Message #1 by "Breidenbach, Beth" <Beth.Breidenbach@g...> on Wed, 26 Dec 2001 22:48:57 -0500
Change the line



" Set adoRS = adoCmd.Execute"



to 



"adoRS.Open adoCmd, , 3"



(3 = the adOpenStatic cursor location)



Beth Breidenbach



-----------------------------------------------





Thanks for your responses ... I tried what everyone suggested ... no joy ...

but I may have been taking suggestions out of context ... here's the test I

built to try getting just the records in selection. It does work, the loop

properly shows 4 records when run against my database. This is almost

straight out of the WROX books.

 

Dim adoConn, adoCmd, adoRS, strConnectionString, intRecords

 

'create ADO Objects 

Set adoConn = Server.CreateObject("ADODB.Connection") 

Set adoCmd = Server.CreateObject("ADODB.Command") 

Set adoRS = Server.CreateObject("ADODB.Recordset") 

 

'open ADO Connection 

strConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User

ID=sa;PASSWORD=sa;Initial Catalog=Members;Data Source=cdukes;Locale

Identifier=2057;Connect Timeout=15;Use Procedure for Prepare=1;Auto

Translate=True;Packet Size=4096;Workstation ID=cdukes" 

 

'set ADO Command properties 

adoCmd.CommandType = adCmdText 

adoCmd.CommandText = "SELECT * FROM MemberTemp" 

 

'Open the Connection 

adoConn.Open strConnectionString 

 

'associate the Command with the Open Connection 

adoCmd.ActiveConnection = adoConn 

 

'retrieve recordset 

Set adoRS = adoCmd.Execute 

 

'Count the records found 

intRecords=adoRS.RecordCount 

 

Do While not adoRS.EOF 

Response.Write vbcrlf 

Response.Write adoRS("Key").value 

adoRS.MoveNext 

Loop 

 

Response.Write "The Number of Records found = " & intRecords  

 

'Close the connection and void the variables 

adoConn.Close 

Set adoConn = nothing 

Set adoCmd = nothing 

Set adoRS = nothing

---


  Return to Index