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

pulling all the records from a table....

Status
Not open for further replies.

Garabaldi

Technical User
Jan 16, 2002
61
CA
Hi folks,

Here's the situation.

I'm trying to pull all the records from a table and write them to an ASP page.
How do I set up a loop in the ASP script that'll write the record, then move to the next record until they all the records have been written.

Thanks very much...
 
Try something like this:

'Open Database
Set objConn = Server.CreateObject ("ADODB.Connection")
Set objRec = Server.CreateObject ("ADODB.Recordset")
objConn.open strConn
'Create Query String
strSQL = "SELECT * FROM TableName "
'Open Recordset
set objRec = objConn.execute (strSQL)
do while not objRec.EOF
write your database info here.
loop
Response.Write strDept
'clean up
objRec.Close
objConn.Close
Set ObjRec = nothing
Set ObjConn = nothing
%>


or do a search on GetRows method.
 
mithrihall, i believe you forgot one step. forgive me if i'm wrong.

'Open Database
Set objConn = Server.CreateObject ("ADODB.Connection")
Set objRec = Server.CreateObject ("ADODB.Recordset")
objConn.open strConn
'Create Query String
strSQL = "SELECT * FROM TableName "
'Open Recordset
set objRec = objConn.execute (strSQL)
do while not objRec.EOF
write your database info here.
objRec.Movenext
loop
Response.Write strDept
'clean up
objRec.Close
objConn.Close
Set ObjRec = nothing
Set ObjConn = nothing
%>

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

otherwise you'll be stuck in an infinite loop. bad.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top