help with random records
im trying to generate a random record from my database using an oledbconnection. my code is shown below where i genereate a random number, match the number to a "QuestionNo" field in my database, and then try and get it to print out the record. but so far i can get it to generatea random number, but i dont kno if it is matching it to the Table and i cant get it to print out. please help.....
Dim objConnection as New OledbConnection(strConnection)
Dim strSQL as string
objConnection.Open()
Dim t as integer
Randomize
t = CInt(Int((10 * Rnd()) + 1))
example.InnerHtml = "Random Number : " & t
strSQL = "SELECT * FROM Table1 WHERE QuestionNo = " & t &""
Dim objCOmmand as New OledbCommand(strSQL, objConnection)
objCommand = New OleDbCommand(strSQL, objConnection)
objCommand.ExecuteNonQuery()
objConnection.Close()
Dim objDataReader as OledbDataReader
objConnection.Open()
objConnection.Close()
response.write (strSQL)
end sub
|