PDA

View Full Version : Need help to do randomize


dominicosavio
09-02-2002, 10:58 AM
Don't know what wrong with this code. Please help

set rs= Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = connString
rs.Source = "SELECT COUNT(ID) AS Total FROM mTABLE"
rs.Open()

Dim vTotal
vTotal = rs.fields.item("Total")

Dim vRandom
Randomize
vRandom = Int((vTotal * Rnd) + 1)
rs.Close()

rs.Source = "SELECT Source, Quote FROM mTABLE WHERE ID = '" + vRandom + "'"
rs.CursorType = 0
rs.CursorLocation = 2
rs.LockType = 3
rs.Open()


connString is defined in an include, and here is the error

Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "SELECT Source, Quote"]'

Thank you

whammy
09-03-2002, 05:36 PM
That should read:

rs.Source = "SELECT Source, Quote FROM mTABLE WHERE ID = '" & vRandom & "'"

:D

dominicosavio
09-05-2002, 10:33 PM
thank you so much. Comimg from java side, I still got a lot of adjustments