SQL data into array

I

Igal

hay, i'm new to ASP, worked mostly with php, so here's my question.

i take data from the sql server like this:

....
set con=Server.CreateObject("adodb.connection")
set rs=Server.CreateObject("adodb.recordset")

SqlExp = "SELECT * FROM content"
rs.Open SqlExp,con,3,3

Response.Write rs("PageName")
....

now, sure it works nice with only one row, but if i have several row in
my Table, my guess i need to put data into an array?

so, how do i put my fields into an array and display them?
 
S

Slim

Igal said:
hay, i'm new to ASP, worked mostly with php, so here's my question.

i take data from the sql server like this:

...
set con=Server.CreateObject("adodb.connection")
set rs=Server.CreateObject("adodb.recordset")

SqlExp = "SELECT * FROM content"
rs.Open SqlExp,con,3,3

Response.Write rs("PageName")
...

now, sure it works nice with only one row, but if i have several row in
my Table, my guess i need to put data into an array?

so, how do i put my fields into an array and display them?

you can simply loop thought the recordset like this

do until rs.eof
reponse.write rs("PageName")
rs.MoveNext
loop


or you can put the records set into a array like this

myArray = rs.gerRows()
 
B

Bob Barrows [MVP]

Igal said:
hay, i'm new to ASP, worked mostly with php, so here's my question.

i take data from the sql server like this:

...
set con=Server.CreateObject("adodb.connection")
set rs=Server.CreateObject("adodb.recordset")

SqlExp = "SELECT * FROM content"
rs.Open SqlExp,con,3,3

Response.Write rs("PageName")
...

now, sure it works nice with only one row, but if i have several row
in my Table, my guess i need to put data into an array?

so, how do i put my fields into an array and display them?

My advice would be to avoid the recordset loop and use the GetRows, or
GetString approach whenever possible:
http://databases.aspfaq.com/database/should-i-use-recordset-iteration-or-getrows-or-getstring.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top