New topic: listbox and realsql.
<http://forums.realsoftware.com/viewtopic.php?t=46533> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message carlbutler7 Post subject: listbox and realsql.Posted: Sat Jan 12, 2013 5:45 am Joined: Tue Jan 08, 2013 8:27 pm Posts: 8 can someone please help me? i have currently got a listbox and a delete button and my listbox shows the realsql results, the delete button works but only deletes the top entry on the listbox how can i get it to delete the current highlighted box, thanks dim db as database = komplete Dim rs as RecordSet = komplete.SQLSelect("select * from Tenants") rs.DeleteRecord db.Commit ListBox1.ColumnCount=4 ListBox1.HasHeading=True ListBox1.Heading(0)="Address" ListBox1.Heading(1)="Title" ListBox1.Heading(2)="First Name" ListBox1.Heading(3)="Surname" listbox1.DeleteAllRows dim sql as string sql = "SELECT * FROM Tenants" dim data as RecordSet data = komplete.SQLSelect(sql) if data <> Nil then while not data.EOF listbox1.AddRow(data.field("currentaddress").StringValue, data.field("title").StringValue, _ data.field("firstname").StringValue, data.field("surname").StringValue) data.MoveNext wend data.Close end if this is my current delete button action. Top elChupete Post subject: Re: listbox and realsql.Posted: Sat Jan 12, 2013 8:42 am Joined: Fri Jun 05, 2009 11:50 am Posts: 328 Location: Hamburg, Germany What is your goal? Do you want to - delete all selected lines from the list box, but not from the DB? - delete all selected listbox lines from the database and repopulate the listbox? if A) iterate through all listbox rows (from last to first), check selected property and if selected use listbox.removerow(line no.) if B) a good way to start is to have the unique primary key of a record stored in the celltag. iterate through listbox, check selected property of each row. if selected, add primary key to a string as Quote:'first primary key', 'second primary key', 'third primary key' once all primary key of the DB records that should be deleted, execute following sql "delete from table where <primary key> in ("+string holding the keys+")" db.commit repopulate listbox _________________ Best regards Stefan Mac OSX 10.8.1 on a MacBook Pro 2.66 GHz Intel Core i7/ RB Professional 2011 Release 3 Top carlbutler7 Post subject: Re: listbox and realsql.Posted: Sat Jan 12, 2013 11:14 am Joined: Tue Jan 08, 2013 8:27 pm Posts: 8 sorry i forgot to mention i was a beginner that has just confused me, lol sorry 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]
