Request.querystring or Recordset.GetString?

Request.querystring or Recordset.GetString?

am 28.02.2005 18:57:02 von andrewdreib

I am still very new to ASP and am trying to create an ASP page that gets
records randomly from a database. Right not I can successfully get one
field of
information at a time and randomize it, but I need the whole string. I've
been searching the internet trying to find an answer to this question and I
found these two commands Request.querystring and Recordset.GetString, but I
don't think I know how to use them properly.

Here's the code I have now:

====================

‘Connection String and SQL statement

Dim query, connStr

query = “select * from numbers”

connStr = “Provider=Microsoft.Jet.OLEDB.4.0;” & _

“Data Source = F:\Inetpub\wwwroot\numbers.mdb;”



‘Opening Database

Dim rs

Set rs = Server.CreateObject(“ADODB.Recordset”)

rs.Open query, connStr, 3, , adCmdText



‘Generating random number from total number of records

Dim intRnd

Randomize Timer

intRnd = (Int(RND * rs.RecordCount))



‘Now moving the cursor to random record number

rs.Move intRnd



‘Showing the random statement

Response.Write “” & rs(“ID”) & “”



‘Closing the database

rs.Close

Set rs = Nothing

====================

Any help would be greatly appreciated, I'm running short on time.

~Andrew

Re: Request.querystring or Recordset.GetString?

am 28.02.2005 22:03:38 von joe

When you say that you need the 'whole string', what do you mean? If
you are trying to get other fields values from your random record, then
simply write them to your page before you close your recordset.

If your db is setup something like...

ID city state
===========================
1 city1 state1
2 city2 state2

then the code that you posted...

Response.Write "" & rs("ID") & ""

could be changed to...

with response
..Write "" & rs("ID") & ""
..write "
"
..write rs("city")
..write "
"
..write rs("state")
end with

Hope it helps.

Re: Request.querystring or Recordset.GetString?

am 28.02.2005 22:52:57 von reb01501

andrewdreib wrote:
> I am still very new to ASP and am trying to create an ASP page that
> gets records randomly from a database. Right not I can successfully
> get one field of
> information at a time and randomize it, but I need the whole string.
> I've been searching the internet trying to find an answer to this
> question and I found these two commands Request.querystring and
> Recordset.GetString, but I don't think I know how to use them
> properly.
>
I'm not sure why you think Request.querystring (which is a Collection, not a
command) is relevant.

See this article for some ideas:
http://www.aspfaq.com/show.asp?id=2467

-
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.