New topic: Some Listbox to Database suggestions needed
<http://forums.realsoftware.com/viewtopic.php?t=45941> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message jerryab Post subject: Some Listbox to Database suggestions neededPosted: Thu Nov 15, 2012 10:16 pm Joined: Mon Dec 12, 2011 7:25 pm Posts: 114 Location: Grand Rapids MI Area What I would like to do is add items to a database from a listbox and Text Area(PictureComments). When you click on a row in the listbox it needs to show the comments in a text area that is assigned (some how) to that row of information. I have a table in a database called (TripHistoryPictures) with 5 Fields (TPID, THID, PictureTitle, PicturePathName and PictureComments). I have a listbox with 5 columns, 2 that show a Thumbnail picture, PictureTitle, and 3 hidden columns PicturePathName TPID, THID. THID is an ID used to create the record. It is an ID that all picture information will be stored by for each record. All the data for these pictures is part of a trip history record. Each trip has an THID. This ID is the only ID common to all picture information from the listbox for the THID database record. TPID is the (INTEGER NOT NULL PRIMARY KEY) in the database and auto increments for each row of information, this allows for multiple pictures for one record under the THID. The TPID does not get assigned untill the listbox has been saved to the database. I think I will need to repopulate the listbox after saving to the database so I can retrieve the TPID and maybe use it to tie the comments(text area) to the listbox. I know how to populate the listbox from the database, What I not sure how to do is add the data from the listbox to the database. Lets say the listbox has been populated from a users selection of pictures or not yet populated. I get the full path and picture name when this is done and show a thumbnail also. First I would like to compare all the rows to the users selected choices by the PicturePathName Column to make sure there are no duplicates added to the listbox. I'm thinking when the user selects pictures some how check the list box to see if the PicturePathName exist already before adding it to the listbox. Then there is the issue of saving the listbox and picture comments(a text area) to the database. Each picture can have a comment and I some how need to tie the comments(text area) with the picture(row) of information. Thats where I'm not sure how to do this. What If most of the data exist already for the record but a few more pictures were added to the listbox or the PictureTitle was changed or comments added or changed. Would I need an ID in the listbox to tie the comments(text Area) to the row of information ? Maybe a Comment ID also in the database and another column in the listbox to tie them together ?. Would I delete all the records from the database using the THID(common to all picture information for one record) and then add the listbox back to the database ? What is the best way to do this. Any suggestions would be very helpful, I'm lost.... I hope this is enough information to get some suggestions from. _________________ iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Lion 10.7.3 and Windows 7 Toshiba Laptop Running Windows 7 & WinXP SP3 REAL Studio Enterprise Edition 2012r1 http://www.theultimatecampgroundlog.com Being rewritten for the Mac Top timhare Post subject: Re: Some Listbox to Database suggestions neededPosted: Fri Nov 16, 2012 1:53 am Joined: Fri Jan 06, 2006 3:21 pm Posts: 11808 Location: Portland, OR USA Add another column to the listbox (hidden) and store the comments in it. In the Change event, copy the comments from that column to the TextArea. There are 2 possible approaches to use. 1) Have the user populate the Trip History information and the Trip History Pictures listbox and then save everything to the database all at once. 2) Save each Trip History Pictures line item (row of the listbox) as it is entered. In this scenario, you would save the Trip History data when the first Trip History Picture is added, then add that Trip History Picture. That way, you have the THID to use in the Trip History Picture. I use 2) whenever I'm dealing with a header and line items situation. It seems more resilient to me. If the program crashes, they may lose one line, but the rest is saved. HTH, Tim Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 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]
