Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 9th, 2004, 06:08 AM
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default updating many to many

Hi everybody,
Im rebuilding a course database for a college's website and im in need of some advice.

I have a selection box which im using for selecting multiple subjects.
As there is a many to many relationship i have a table for joining the records. When updating the course I want the previously selected subjects to be selected when the page loads so the user can unselect them to remove that subject from the course. would my best option be to delete the previous records then add them all again?
Reply With Quote
  #2 (permalink)  
Old March 10th, 2004, 12:21 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

That's usually the way you have to do it because there's no simple way to telling from the posted data of an HTML form what was "un-selected". This applies to checkboxe and select controls. The easiest way is to just clean out all records applicable then add in the selected ones.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #3 (permalink)  
Old March 11th, 2004, 05:34 AM
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Another thing. I first thought getting the already selected options selected when the page loads would be a simple case of checking against the record set, forgetting that it would have to loop through each record in the rs for each option, is there a better way? would it be best to put all the id numbers into a string then doing an instr() for each option, this page is only going to be used by a few people at a time (like 3 or 4 max)

thanks for your help
Andy
Reply With Quote
  #4 (permalink)  
Old March 11th, 2004, 10:20 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I think in the end you are best off to just delete all appropriate rows and then insert the currently selected ones.

Think about it this way... what makes more sense:

A) select current rows from DB, loop thru results, test against current selected items, figure out which to remove, remove them, add new ones.

B) Remove all applicable rows, add all selected items.

Why do all that extra work in option A)? It's going to be less efficient and more hastle.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #5 (permalink)  
Old March 11th, 2004, 12:58 PM
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thats for all the advice :)
i thought this was going to take a while to figure out as im only a novice. Its only taken me a couple of hours to get the whole thing done.
Nice one mate!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating a datagrid jgrant ASP.NET 2.0 Basics 0 August 25th, 2007 07:34 PM
Updating Labels in C# dranne C# 3 April 10th, 2007 12:37 AM
Updating Recordset arholly Access VBA 16 December 27th, 2006 01:28 PM
database not updating ellie BOOK: Beginning ASP 3.0 1 April 16th, 2006 05:28 AM
Updating dmurray Access 1 June 25th, 2003 05:41 PM



All times are GMT -4. The time now is 09:26 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.