New topic: Another DB Problem
<http://forums.realsoftware.com/viewtopic.php?t=37727> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message S.Rampling Post subject: Another DB ProblemPosted: Sat Feb 19, 2011 1:06 am Joined: Sat Jan 08, 2011 4:47 pm Posts: 81 Location: Sydney, Australia How do I stop the data Doubling up in the Database if a user presses the save button more than once, I am using the following code. Code: //Add to engines Database Dim dr as new DatabaseRecord dr.column("name") = trim(txtname1.text) dr.column("class") = trim(txtclass1.text) dr.column("date") = trim(txtdate1.text) dr.column("temp") = trim(txttemp1.text) dr.column("weather") = trim(txtweather1.text) dr.column("wheels") = trim(txtwheels1.text) dr.column("wheeltype") = trim(txtwheeltype1.text) dr.column("hlength") = trim(txthlength1.text) dr.column("spacers") = trim(txtspacers1.text) dr.column("caster") = trim(txtcaster1.text) dr.column("camber") = trim(txtcamber1.text) dr.column("comments") = trim(txtcomments1.text) //Add to Database karter.InsertRecord "tracks1",dr karter.Commit The more times the save button is presses the more times the same record is added to the database. Thanks Shane. Top jefftullin Post subject: Re: Another DB ProblemPosted: Sat Feb 19, 2011 1:11 am Joined: Wed Nov 15, 2006 3:50 pm Posts: 2138 Location: England Well, you are using InsertRecord. That kinda means 'add a record', so it's doing what it's told. There are several approaches here. a) If your records had a unique ID, you can get the db to reject any attempt to add a new row with the same ID b) Before saving, check if a record with the same details exists, if yes, UPDATE it, if no, INSERT it c) Disable the save button after a save until some data has been changed on screen Top S.Rampling Post subject: Re: Another DB ProblemPosted: Sat Feb 19, 2011 1:51 am Joined: Sat Jan 08, 2011 4:47 pm Posts: 81 Location: Sydney, Australia Thanks Jeff, only learning at the moment. Would you have a brief example of what you are saying, I don't quite follow it. Quote:a) If your records had a unique ID, you can get the db to reject any attempt to add a new row with the same ID b) Before saving, check if a record with the same details exists, if yes, UPDATE it, if no, INSERT it c) Disable the save button after a save until some data has been changed on screen Thanks Shane. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- 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]
