Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about SQL and VBScript

Status
Not open for further replies.

lyric0n

Technical User
Dec 28, 2005
74
When I use the following code below...how exactly is it moving through the recordset? Does it get the entire record set when I say Open, or does it get each row when I say to move next?

strcnSQL = "Provider=SQLOLEDB;Server=TEST;Database=TEST;uid=TEST;pwd=TEST"
Set cnSQL = Wscript.CreateObject("ADODB.Connection")
cnSQL.Open strcnSQL
Set rsTesting = Wscript.CreateObject("ADODB.Recordset")
strSQL = "SELECT TOP 100 PERCENT " & selectQuery &_
" FROM " & fromQuery &_
" WHERE " & whereQuery

rsTesting.Open strSQL, cnSQL, adOpenForwardOnly
rsTesting.MoveFirst

While Not(rsTesting.EOF)
msgbox(rsTesting(SomeData))
rsTesting.MoveNext
Wend

 
lyricOn,
i believe that he entire record set is retrieved, the move next just changes which specific record the pointer is on.
regards,
longhair
 
If you have the SQL Server administrative tools installed you can connect to your server using the Profiler program and do a trace to see the same messages your SQL Server sees.
 
If the recordset is large (i.e. hundreds of records or more) then only some of the records will be extracted and scrolling through the recordset will cause more records to be retrieved. If the number of records is small then (usually) all the records are returned when you open the recordset. You may not get an accurate recordcount until you have moved to the end of the recordset and forced all records to be loaded.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top