New topic: 

MYSQL : issue with rs.edit within a rs.eof loop

<http://forums.realsoftware.com/viewtopic.php?t=47540>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        terreywe          Post subject: MYSQL : issue with rs.edit 
within a rs.eof loopPosted: Mon Apr 08, 2013 4:42 am                         
Joined: Wed Oct 31, 2012 11:21 pm
Posts: 11                Hi all, 

looking for some help here....the scenario is there is an update for a data, 
therefore need to scan the table for the old data, and change the value to the 
new data......using rs.edit for editting, and using rs.eof for the loop process

also fyi, product ID is not the index ID, just to clarify on that..

the code is :
********************************
  sql = "select  * from product_info where prd_id ='"+str(p_id_old)+"'  "  //** 
p_id_old is the old product ID reference.
  dim rs as recordset = db.SQLSelect(sql)
  
  while not rs.eof

  rs.edit
  rs.field("prd_id ").StringValue = vivpid(ps).Text  //**(replaced old ID whit 
the new id taken from a textfield)
  rs.Update

  if db.Error then
  MsgBox db.ErrorMessage
  end if

  msgbox "successful"
  // msgbox "successful2"  (this msgbox when enabled does something strange)

  rs.MoveNext

  wend
  
  db.Commit
  
  rs.close
******************************** 

so, for this example, there are 3 records, found...and when this action is 
triggered...the msgbox "successful" repeats 3 times, which seems to point that 
it was able to locate all 3 records and update it...but when the DB is 
checked....only the 1st record is changed....the other 2 didnt change, but no 
popup error for failure.even placing the db.commit in the loop doesnt help too.

also, if i enable the "msgbox "successful2"" , then strangely this time around 
da 1st and 2nd record is changed.....which is rather weird....i have no idea 
why the msgbox triggers the data editing, but if there were 100+ records, i 
cant place and have the msgbox repeat 100+ time too....

any suggestions? or is this code wrong somehow? appreciate any help in regards 
to this issue, as it is a bit strange....and once again thanks.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to