New topic: Database record delete button
<http://forums.realsoftware.com/viewtopic.php?t=46686> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message Roll Post subject: Database record delete buttonPosted: Thu Jan 24, 2013 8:32 pm Joined: Thu Jan 24, 2013 8:08 pm Posts: 1 Hi, first post. I checked many posts and tried examples but having no luck. I use RB to create small projects for myself. The only database I created years ago was to hold my passwords. It has worked great for many years. Acting a little weird on Mt. Lion so I want to update. Yes, I used the evil database query and data control, please forgive me. But now I want to "man up" and code right! Now I can create a database with a table, add data to it, and display it in a listbox. Whoopdy do! But this is what I want. I want my delete button to do exactly the same thing it used to do back when I used the bindings. You know, select a row in the listbox click the delete button and bingo, done. Seems so simple, but I can't do it! So much for "manning up" in code. What did that magical binding together with those evil controls do so easily? As you can see I'm not a database-er. Please help if you get a moment. Thanks, Richard Top DaveS Post subject: Re: Database record delete buttonPosted: Thu Jan 24, 2013 10:24 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4459 Location: San Diego, CA What makes a row in your database unique? A RowID? or??? SQLite for example has a built in CID (column id) value in any event... execute this SQL statement DELETE FROM mytable WHERE unique_field="unique_value" DELETE FROM mytable where CID=42 myTable is name of your table unique_field is a Field in your Table and "unique_value" is a value IN that field that identifies the row (or rows) to be deleted Once deleted.. you will also have to delete the Listbox Row (listbox1.remove x) _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top HMARROQUINC Post subject: Re: Database record delete buttonPosted: Thu Jan 24, 2013 11:07 pm Joined: Sun Jan 25, 2009 5:11 pm Posts: 344 Location: Guatemala, Central America Does your listbox has a column where you "show" the unique identifier for that record? if not store it using rowid and when the user selects the row in the listbox read that value, if the value is being displayed then get the value from the cel. Once you got the unique identifier value use the code that Dave posted or a variation of it. _________________ Future RS guru 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]
