SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 30th, 2003, 12:49 AM
dj_in_Idaho dj_in_Idaho is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Boise, ID
Posts: 3 dj_in_Idaho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to dj_in_Idaho
Question How to Update Join Tables?

I have a question about JOIN'ed table in Access. I have 2 tables in my database with one being tbl_Events and the other tbl_VolunteerSchedule. tbl_Events contains information regarding upcoming Events. tbl_VolunteerSchedule contains the names of Volunteers plus information from tbl_Events pertaining to the event the volunteer is volunteering for. What I need is for tbl_Volunteer to Update when I make changes to the Events in tbl_Events. I thought that it was working correctly when I used a LEFT JOIN. However if I make updates to tbl_Events it adding additional record to tbl_Volunteer. It should only Update tbl_VolunteerSchedule when the fields EventID match. Does this make sense? Thanks.


If Request.Form("Action") = "Modify >>>" Then

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=volunteerman"
Updates = Updates & "tbl_Events.ModifiedBy = " & Checkstring(Request("ModifiedBy"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.ModifiedBy = " & Checkstring(Request("ModifiedBy"), ", ")
Updates = Updates & "tbl_Events.DateModified = " & Checkstring(Request("DateModified"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.DateModified = " & Checkstring(Request("DateModified"), ", ")
Updates = Updates & "tbl_Events.EventName = " & Checkstring(Request("EventName"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.EventName = " & Checkstring(Request("EventName"), ", ")
Updates = Updates & "tbl_Events.EventCity = " & Checkstring(Request("EventCity"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.EventCity = " & Checkstring(Request("EventCity"), ", ")
Updates = Updates & "tbl_Events.EventLocation = " & Checkstring(Request("EventLocation"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.EventLocation = " & Checkstring(Request("EventLocation"), ", ")
Updates = Updates & "tbl_Events.EventDate = " & Checkstring(Request("EventDate"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.EventDate = " & Checkstring(Request("EventDate"), ", ")
Updates = Updates & "tbl_Events.EventStartTime = " & Checkstring(Request("EventStartTime"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.EventStartTime = " & Checkstring(Request("EventStartTime"), ", ")
Updates = Updates & "tbl_Events.EventEndTime = " & Checkstring(Request("EventEndTime"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.EventEndTime = " & Checkstring(Request("EventEndTime"), ", ")
Updates = Updates & "tbl_Events.EventInformation = " & Checkstring(Request("EventInformation"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.EventInformation = " & Checkstring(Request("EventInformation"), ", ")
Updates = Updates & "tbl_Events.EventCoordinator = " & Checkstring(Request("EventCoordinator"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.EventCoordinator = " & Checkstring(Request("EventCoordinator"), ", ")
Updates = Updates & "tbl_Events.CoordinatorPhone = " & Checkstring(Request("CoordinatorPhone"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.CoordinatorPhone = " & Checkstring(Request("CoordinatorPhone"), ", ")
Updates = Updates & "tbl_Events.CoordinatorEmail = " & Checkstring(Request("CoordinatorEmail"), ", ")
Updates = Updates & "tbl_VolunteerSchedule.CoordinatorEmail = " & Checkstring(Request("CoordinatorEmail"), " ")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=volunteerman"
SQL = "UPDATE tbl_Events LEFT JOIN tbl_VolunteerSchedule ON tbl_Events.EventID = tbl_VolunteerSchedule.EventID SET " & Updates & "WHERE tbl_Events.EventID = " & Request.QueryString("EventID")
Conn.Execute(SQL)
Conn.close

Reply With Quote
  #2  
Old August 9th, 2003, 01:10 AM
zimm zimm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 30 zimm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Couple things here.

Building strings the way you have here consumes resources. Secondly, all of that crud eats up bandwidth when you pass that query to your database.

Instead of all of that, create a procedure in Access and then create parameter objects for a command object. It's about the same amount of work as what you have, but it's much more readable.

At any rate, since this is such an ugly query to begin with, you still need to create a procedure. Create the procedure as a select query, providing parameters which you KNOW will return the data that you want.

Next: left outer join and right outer join are absolutely interchangeable. It just depends on which table you select (or in your case, update) from first. Obviously in your case, you only want to update the fields where you've not gotten any null values returned. Best I can tell you is to change to a right outer join and see if that gets what you want.

Also, if you establish a parent-child relationship between these two tables and enforce referential integrity, you are unlikely to have the kinds of problems you are having now.

Sorry for the vagueness of the answer, but it's the best I can come up with without knowing the nature of your DB.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > How to Update Join Tables?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway