New topic: 

Update Listbox from Database

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

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        Sully73          Post subject: Update Listbox from 
DatabasePosted: Fri Mar 23, 2012 8:16 am                         
Joined: Fri Mar 23, 2012 7:46 am
Posts: 1                I'm new to the RealStudio World, but enjoying it very 
much so far.

I have 2 questions related to databases

1) I have a list box that displays database records in one window and a second 
window where the records are added or edited.  My problem is how do I get the 
list box to update once a record is added or edited.  I tried placing the code 
under the open event for the list box, which works fine to display existing 
records when the listbox is initial opened, however it obviously doesn't update 
when records or added in the second window.


2)I have functioning commands to open or create a new database, but how would 
you have the application default to the last opened database when starting the 
app?

thanks  
Cory   
                             Top                 Jason_Adams          Post 
subject: Re: Update Listbox from DatabasePosted: Fri Mar 23, 2012 8:35 am       
                          
Joined: Fri Nov 10, 2006 4:10 pm
Posts: 1547
Location: Michigan, USA                1) You can either "cheat" by reporting 
the information back to the first window from the second, and adding row that 
way; or set up a timer to perform the query and update the table on a cyclical 
basis. The only advantage to the former is you're not running constant queries 
(depending on the size of your table, but it doesn't sound too big if you're 
displaying everything). I'd probably do the later, though, and set it to query 
every second or so — again, depending on the expected size of the table.

2) I'm assuming you're using RealSQLDatabase. You'd want to use some sort of 
setting storage on the users machine — e.g., INI, plist, etc (I have a free 
INI class available ) — in which case you'd store the database name and path. 
Then, when you open, read said file, grab the name and path, present the name 
to the user (if you want to offer them to use it), then get the FolerItem for 
the database from the path.

Hope this helps.     
_________________
Windows 7 Ultimate x64
Windows XP Pro SP3
Ubuntu 11.04 via Virtual Box
RS Enterprise 2011r4

Programming Tutorials & Free Projects: http://www.JasonTheAdams.com
"Christianity has not been tried and found wanting; it has been found difficult 
and not tried." - G.K. Chesterton  
                             Top                 markwalsh          Post 
subject: Re: Update Listbox from DatabasePosted: Fri Mar 23, 2012 12:18 pm      
                   
Joined: Wed May 20, 2009 4:43 pm
Posts: 750                Another option for question #1 would be to make your 
'edit' window a modal window (to prevent user from exiting that window until 
they have finished editing the record), and then in your calling window, you 
can check to see if changes have been made (set a flag in the edit window) and 
reload the listbox if necessary.

Another way could be to set a delegate in your edit window when it is opened 
from your list window. If the record is updated, run the delegate function. I 
have never actually used this method myself, but I believe it should work.      
_________________
RB 2009r4 Windows XP  
                             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]

Reply via email to