Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Getting two of my tables to work together


Message #1 by "Mark" <mark.d.williams@b...> on Mon, 4 Mar 2002 16:33:50
Hi All,



In my database I have 2 tables, one has the majoirty of the product 

details (price, description etc). It also has an area_id number for each 

record. The second has a list of area_titles with an area_id assigned to 

each. 



What I need to do is get the two working together so the area_id is 

replaced by the are_title from the foirst table. I can get this to work 

if I am showing a single record on the page by saving the area_id as a 

varibale and then selecting the Title from the other table IF area_id = 

myvariable. This is fine, but I need to loop the recordset so I show all 

records on the page, with their respective area_titles.



<%

set rsProperty = Server.CreateObject("ADODB.Recordset")

rsProperty.ActiveConnection = "dsn=db1;"

rsProperty.Source = "SELECT * FROM property WHERE state_of_trade_id = 1 

OR state_of_trade_id = 2"

rsProperty.CursorType = 0

rsProperty.CursorLocation = 2

rsProperty.LockType = 3

rsProperty.Open()

rsProperty_numRows = 0

%>

<%

Dim iArea_ID

iArea_ID = (rsProperty.Fields.Item("area_id").Value)

%>

<%

set rsArea = Server.CreateObject("ADODB.Recordset")

rsArea.ActiveConnection = "dsn=db1;"

rsArea.Source = "SELECT * FROM area WHERE area_ID = " & _

iArea_ID

rsArea.CursorType = 0

rsArea.CursorLocation = 2

rsArea.LockType = 3

rsArea.Open()

rsArea_numRows = 0

%>

<%

Dim Repeat1__numRows

Repeat1__numRows = 10

Dim Repeat1__index

Repeat1__index = 0

rsProperty_numRows = rsProperty_numRows + Repeat1__numRows

%>



<body>



<% 

While ((Repeat1__numRows <> 0) AND (NOT rsProperty.EOF)) 

%>

<%=(rsProperty.Fields.Item("description").Value)%>,

<%=(rsArea.Fields.Item("area_iTtle").Value)%>

<% 

  Repeat1__index=Repeat1__index+1

  Repeat1__numRows=Repeat1__numRows-1

  rsProperty.MoveNext()

Wend

%> 





Many thanks,



Mark

  Return to Index