ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 17th, 2003, 07:19 PM
arlie arlie is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 1 arlie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old September 18th, 2003, 01:04 AM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 7
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")

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Help with update


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT