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
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