stuck on random record code example from ASPFAQ.com
am 07.11.2005 23:49:48 von Mike
Hello,
Here's my code:
<%
Randomize()
randNum = (CInt(1000 * Rnd) + 1) * -1
set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\brink-premfs1\sites\[deleted];" & _
"Persist Security Info=False"
sql = "SELECT TOP 1 cols, r = Rnd(" & randNum & ") FROM
settings_gravity ORDER BY r"
set rs = conn.execute(sql)
response.write "
gravity: " & rs(0)
' ...
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Here's the settings_gravity table:
id autonumber
setting double number
for example, setting includes: 1, 1.25, 1.5 etc...
I get this error:
Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
/netmech/randomskirmish.asp, line 13 <--the "set rs =
conn.execute(sql) " line
Any ideas what I am doing wrong???
thanks,
Mike
Re: stuck on random record code example from ASPFAQ.com
am 08.11.2005 01:31:12 von reb01501
mike wrote:
> Hello,
>
> Here's my code:
>
> <%
> Randomize()
> randNum = (CInt(1000 * Rnd) + 1) * -1
>
> set conn = server.CreateObject ("ADODB.Connection")
> conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=\\brink-premfs1\sites\[deleted];" & _
> "Persist Security Info=False"
>
> sql = "SELECT TOP 1 cols, r = Rnd(" & randNum & ") FROM
> settings_gravity ORDER BY r"
>
> set rs = conn.execute(sql)
>
> response.write "
gravity: " & rs(0)
>
> ' ...
> rs.close: set rs = nothing
> conn.close: set conn = nothing
> %>
>
> Here's the settings_gravity table:
>
> id autonumber
> setting double number
>
> for example, setting includes: 1, 1.25, 1.5 etc...
>
> I get this error:
> Microsoft JET Database Engine error '80040e10'
>
> No value given for one or more required parameters.
>
> /netmech/randomskirmish.asp, line 13 <--the "set rs =
> conn.execute(sql) " line
>
>
> Any ideas what I am doing wrong???
>
Try
" ... ORDER BY Rnd(" & randNum
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Re: stuck on random record code example from ASPFAQ.com
am 09.11.2005 19:45:10 von Chris Hohmann
"Bob Barrows [MVP]" wrote in message
news:ufIr8u$4FHA.3544@TK2MSFTNGP09.phx.gbl...
> mike wrote:
>> Hello,
>>
>> Here's my code:
>>
>> <%
>> Randomize()
>> randNum = (CInt(1000 * Rnd) + 1) * -1
>>
>> set conn = server.CreateObject ("ADODB.Connection")
>> conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
>> "Data Source=\\brink-premfs1\sites\[deleted];" & _
>> "Persist Security Info=False"
>>
>> sql = "SELECT TOP 1 cols, r = Rnd(" & randNum & ") FROM
>> settings_gravity ORDER BY r"
>>
>> set rs = conn.execute(sql)
>>
>> response.write "
gravity: " & rs(0)
>>
>> ' ...
>> rs.close: set rs = nothing
>> conn.close: set conn = nothing
>> %>
>>
>> Here's the settings_gravity table:
>>
>> id autonumber
>> setting double number
>>
>> for example, setting includes: 1, 1.25, 1.5 etc...
>>
>> I get this error:
>> Microsoft JET Database Engine error '80040e10'
>>
>> No value given for one or more required parameters.
>>
>> /netmech/randomskirmish.asp, line 13 <--the "set rs =
>> conn.execute(sql) " line
>>
>>
>> Any ideas what I am doing wrong???
>>
>
> Try
> " ... ORDER BY Rnd(" & randNum
>
> Bob Barrows
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
To add to what Bob said, you'll also want to replace "cols" with the list of
columns you want to retrieve from your table. Something like this (watch out
for line wrapping).
sql = "SELECT id, setting, r = Rnd(" & randNum & ") FROM settings_gravity
ORDER BY Rnd(" & randNum & ")"