Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Data from two tables problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Data from two tables problem

 Post Reply Post Reply
Author
srb01 View Drop Down
Newbie
Newbie


Joined: 01 February 2004
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote srb01 Quote  Post ReplyReply Direct Link To This Post Topic: Data from two tables problem
    Posted: 01 February 2004 at 1:05pm

I am using the code below to display a list of results in a table. It is working fine except the ".Write rsName1("grp_code")" section (which is looking for results from another table, is displaying the same value for every record of rsname. How can I get it (rsname1) to display the correct value which matches the record from rsname?

strSQL = "SELECT * FROM Student WHERE syskey = '" & request("syskey") & "'"

stucode = rsname("syskey")
acyear = "03/04"

strSQL1 = "SELECT * FROM stu_grp WHERE stu_code = '" & stucode & "' AND ayrc = '" & acyear & "'"

rsName1.Open strSQL1, adoConn, adOpenDynamic ,adLockReadOnly, adCmdText

While not rsName.EOF

     With Response
           .Write "<tr>"
           .Write "<td>"
           .Write rsName("syskey")

          .Write "</td>"
           .Write "<td>"
           .Write rsName("firstname")
           .Write "</td>"
           .Write "<td>"
           .Write rsName("lastname")
           .Write "</td>"
           .Write "<td>"
           .Write rsName("dob")
           .Write "</td>"
           .Write "<td>"
'*******PROBLEM LINE!!*********
'***DISPLAYS SAME VALUE FOR EVERY RECORD***
           .Write rsName1("grp_code")
           .Write "</td>"
           .Write "</tr>"

     end with
          
'Moves to the next record
rsName.MoveNext

wend
end if

Please help!

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 01 February 2004 at 1:11pm
Change

.Write rsName1("grp_code")

to

.Write rsName("grp_code")
Back to Top
srb01 View Drop Down
Newbie
Newbie


Joined: 01 February 2004
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote srb01 Quote  Post ReplyReply Direct Link To This Post Posted: 01 February 2004 at 1:17pm

the field grp_code does not exist in the table? Perhaps I have made it unclear.

There are two tables one called student and the other called stu_grp. The majority of the results come from student (with the rsName connection), the grp_code comes from stu_grp (with the rsName1 connection). the grp_code field does not exist in the student table.

I would like the correct grp_code value to be outputted next to the correct; syskey, firstname, lastname and dob - being displayed.

Hope thats clearer.

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 01 February 2004 at 2:07pm
Oh sorry, Try this

While not rsName.EOF AND NOT rsName1.EOF

     With Response
           .Write "<tr>"
           .Write "<td>"
           .Write rsName("syskey")            .Write "</td>"
           .Write "<td>"
           .Write rsName("firstname")
           .Write "</td>"
           .Write "<td>"
           .Write rsName("lastname")
           .Write "</td>"
           .Write "<td>"
           .Write rsName("dob")
           .Write "</td>"
           .Write "<td>"
'*******PROBLEM LINE!!*********
'***DISPLAYS SAME VALUE FOR EVERY RECORD***
           .Write rsName1("grp_code")
           .Write "</td>"
           .Write "</tr>"

     end with
         &nbs p;
'Moves to the next record
rsName.MoveNext

wend
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.