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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Standalone Recordset 1

Status
Not open for further replies.

travisbrown

Technical User
Dec 31, 2001
1,016
Okay, why isn't this working? It only creates a recordset with the last row added, each time seemingly overwriting the previous row. I'm sure I've done this before without issue. Is there a PRESERVE switch I'm missing?

Code:
<!--#include file="adovbs.inc" -->
<%
SET rs = createobject("adodb.recordset")
WITH rs.Fields
	.Append "file_name", adChar, 255
	.Append "file_size", adChar, 255
END WITH
rs.Open

	rs.AddNew
	rs("file_name") = "A"
	rs("file_size") = "A"	
	rs.Update
	
	rs.AddNew
	rs("file_name") = "B"
	rs("file_size") = "B"
	rs.Update
	
	rs.AddNew
	rs("file_name") = "C"
	rs("file_size") = "C"
	rs.Update

IF NOT rs.BOF AND NOT rs.EOF THEN
	arr = rs.GetRows()
	FOR i = 0 TO UBOUND(arr,2)
		response.write arr(0,i)
		response.write arr(1,i)
	NEXT
END IF
rs.close
SET rs = Nothing
%>
 
[tt]'etc etc
[red]rs.moveFirst[/red]
IF NOT rs.BOF AND NOT rs.EOF THEN
'etc etc
END IF
'etc etc[/tt]
 
Thanks. That works. I've not used that in other times I've made standalone recordsets.

But when you suggested it, I realized that every other time I'd used something like rs.sort = "file_size", which apparently accomplishes the same thing as rs.movefirst in this case. This time I wasn't sorting, so I'd omitted it, thinking it was of singular function.



 
Rather than relate the phenomenon to any thing else, like rs.sort, visualize what is happening by the little pointer (cursor) to the row the db is keeping track of. getrows() will get rows from thereon-after. It will make the metal approach to other situations more reliable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top