PDA

View Full Version : Can't Get A RecordCount


ScottInTexas
05-06-2003, 08:32 PM
Can someone please tell me why I can't get the recordCount in this code?


set objRS=Server.CreateObject("ADODB.recordset")
With objRS
.CursorType = 2
.Open SQL, DataSource
.MoveLast
.MoveFirst
For intLoop=0 to 3
tempString=tempString & "DataSet" & intLoop+1 & "="
Do while not .EOF
tempString=tempString & objRS(intLoop+1)
If .AbsolutePosition < .RecordCount Then tempString=tempString & ","
Else
tempString=tempString & ";"
End If
.MoveNext
Loop
Response.Write(tempString)
tempString=""
.MoveFirst
Next



I've examined the recordcount with <% =objRS.RecordCount %> and it prints -1. That is before the first record. I do get the data though, so it is opening and cycling through the records! It's just that the commas and the semicolon are in the wrong place.

Thanks

arnyinc
05-06-2003, 09:45 PM
I never liked the way this worked. This page can explain it a lot better than I can.

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=139

ScottInTexas
05-07-2003, 02:40 PM
PERFECT!

Thanks a lot for your response.