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?

Re: SQL data into array by Slim

Slim
Tue Nov 07 05:05:43 CST 2006


"Igal" <igal.alkon@gmail.com> wrote in message
news:1162892153.537709.85950@e3g2000cwe.googlegroups.com...
> 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()




Re: SQL data into array by Bob

Bob
Tue Nov 07 05:37:14 CST 2006

Igal wrote:
> 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

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"