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:
  #1  
Old October 10th, 2003, 02:23 PM
xsoftdev xsoftdev is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Los Angeles, CA
Posts: 64 xsoftdev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 7 sec
Reputation Power: 6
Question More than one recordset in same connection

Hello,

Not sure if this is a DB or ASP question.
I am using ASP with an Access 2000 DB & ADO

I have an ASP page that is used to edit data in 3 tables. 2 of these tables have a one-one relationship, third table contains State and Country information.

My question is how do I write the correct SQL statement that will extract relevant data from all 3 tables and also another statement that will Update the data in all 3 tables.

Do I create 2 recordsets, one for the tables with a relationship and one for State/Country data?

Appreciate your help

---Part of my Update code---
Dim objConnection, objRecordset
Dim strSQL, strMessage

Set objConnection = Server.CreateObject("ADODB.Connection")
Set objRecordset = Server.CreateObject("ADODB.Recordset")
objConnection.Open Application("ConnectionString")

strSQL = "UPDATE Cars SET " & _
"Model = '" & Replace(Request.Form("Model"), "'", "''") & "', " & _
"Make = '" & Replace(Request.Form("Make"), "'", "''") & "', " & _
"Year = '" & Replace(Request.Form("year"), "'", "''") & "', " & _
"WHERE CarsID = " & Replace(Request.Form("cardid"), "'", "''")
' Confirmation message
strMessage = "updated"

'Use the execute method of the connection object the insert the record
objConnection.execute(strSQL)
objConnection.close
set objConnection = nothing

Reply With Quote
  #2  
Old October 11th, 2003, 05:53 AM
ShermanPeabody ShermanPeabody is offline
CDONT[RE:"member"]
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: United States
Posts: 35 ShermanPeabody User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 6 sec
Reputation Power: 6
JOIN tables

Hope this points you in the right direction.

You need to join the tables and select the desired fields.

SELECT Cars.Model, Cars.Make, Table2.fieldA FROM Cars INNER JOIN Table2 ON Cars.CarsID = Table2.fieldB WHERE Cars.Year < 1957

You can use multiple joins in a single statement to pull in all 3 tables. Here is one I was using for something else but joins 3 tables and puts selected fields into recordset.

strSQL = "SELECT DISTINCT G.EventID, E.EventTitle, E.StartDate, E.StartTime FROM (GroupEvents G INNER JOIN MembersGroups M ON G.GroupID = M.GroupID) INNER JOIN Events E ON G.EventID = E.EventID WHERE M.MemberID ='"&Session("MemberID")&"' AND M.IsViewed = Yes AND E.StartDate >= #"&DateRangeBegin&"# AND E.StartDate <= #"&DateRangeEnd

Reply With Quote
  #3  
Old October 11th, 2003, 03:48 PM
xsoftdev xsoftdev is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Los Angeles, CA
Posts: 64 xsoftdev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 7 sec
Reputation Power: 6
Thanks ShermanPeabody.

One followup question, how do you reference the recordset above?

Response.Write(obRecordset("fieldA"))
OR
Response.Write(obRecordset("Table2.fieldA"))

Reply With Quote
  #4  
Old October 12th, 2003, 05:00 AM
ShermanPeabody ShermanPeabody is offline
CDONT[RE:"member"]
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: United States
Posts: 35 ShermanPeabody User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 6 sec
Reputation Power: 6
obRecordset("fieldA")


did the rest of it work out for you?

Reply With Quote
  #5  
Old October 12th, 2003, 02:58 PM
xsoftdev xsoftdev is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Los Angeles, CA
Posts: 64 xsoftdev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 7 sec
Reputation Power: 6
Yes it did, thanks for you help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > More than one recordset in same connection


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 2 hosted by Hostway
Stay green...Green IT