Request.querystring or Recordset.GetString?

A

andrewdreib

I am still very new to ASP and am trying to create an ASP page that gets
records 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 “<b>†& rs(“IDâ€) & “</b>â€



‘Closing the database

rs.Close

Set rs = Nothing

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

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

~Andrew
 
J

Jason Brown [MSFT]

I don't think you want either of those, but I'm not quite clear on what "but
I need the whole string" means.

you're successfully writing the ID field, right? does this mean you want to
write another field too?

in that case:

Response.Write "<b>" & rs("ID") & " : " & rs("anotherfieldnamehere") &
"</b>"

Recordset.GetString() is a method for fast data retrieval that will convert
the WHOLE recordset into a string. I don't think you want that, since you're
grabbing one row, not all. Request.Querystring gets you the query string
from a URL (the bit after ? in http://support.microsoft.com/?kbid=123456 -
Request.Querystring("kbid") would return "123456")


--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top