|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with update
All I'm wanting to do is loop through a recordset and set a file b_random to a random value. For some reason I am totally lost on this one.
Here is my code. As you can see I've played with about everything. strSQLget = "Select b_id, b_random from smallbanners" myconn = "Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\inetpub\wwwroot\testrandom\directo ry.mdb" set rsSQLget = Server.CreateObject("ADODB.Recordset") rsSQLget.OPen strsqlget, myconn, 1 ,2, adCmdTableDirect Do while not rsSQLget.eof Dim rndNumber Randomize Timer rndNumber = (9876 * CInt((RND * 32000) + 100)) response.write rndNumber response.write "<br>" strsql= "update smallbanners set b_random = (9876 * CInt((RND * 32000) + 100*(b_id)))" 'strsql= "update smallbanners set b_random = int(50000*Rnd(b_id))" 'strsql= "update smallbanners set b_random = " & int(50000*Rnd(rndnumber))& "" 'strsql= "update smallbanners set b_random = " & rndNumber & "" 'strsql = "insert into smallbanners (b_random) values (" & rndNumber & ")" set rsUpdate = server.createObject ("adodb.recordset") rsUpdate.open strSQL, myconn rssqlget.update rsSQLget.movenext loop What I would like to do is just set the field b_random to the random number. When I try one of the commented lines every record get the same value. The first strsql does give me different values but they are the same each time. thanks for any help arlie |
|
#2
|
|||
|
|||
|
Your Update SQL does not specify what row to update...so it's updating them all. So even though you may be getting a random number each time through the loop, you're setting all records to that random number each time.
Try it as Code:
strSQL = "update smallbanners set b_random = (random number stuff) where b_id = " & rsSQLget("b_id")
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Help with update |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|