sogoth
New Member
United Kingdom
73 Posts |
Posted - 30 October 2001 : 06:32:11
|
Hi
I've a small problem with the piece of code included at the bottom of the post. When I use the SQL statement from Recordset1 with a CN of 166 I get two different records come back (with con = 62 and 63 as it should be). Ok so those numbers won't mean anything to anyone, but I hope I'm getting across my case ;)
but as soon as I try and run this same statement in the asp page and repeat the region that is supposed to list, I get two records, but both are for the same information rather than the two different records I should recieve.
help!!!
--------------------------
<%@LANGUAGE="VBSCRIPT"%> <!--#include file="Connections/cro.asp" --> <% Dim Recordset1__var Recordset1__var = "0" if (Request.QueryString("CN") <> "") then Recordset1__var = Request.QueryString("CN") %> <% set Recordset1 = Server.CreateObject("ADODB.Recordset") Recordset1.ActiveConnection = MM_cro_STRING Recordset1.Source = "SELECT * FROM Services RIGHT OUTER JOIN Contact ON Services.Ser = Contact.Ser LEFT OUTER JOIN project ON Contact.Con = project.con LEFT OUTER JOIN Notes ON Contact.Con = Notes.con RIGHT OUTER JOIN CompanyName ON Contact.CN = CompanyName.CN WHERE CompanyName.CN = " + Replace(Recordset1__var, "'", "''") + "" Recordset1.CursorType = 0 Recordset1.CursorLocation = 2 Recordset1.LockType = 3 Recordset1.Open() Recordset1_numRows = 0 %> <% set Recordset2 = Server.CreateObject("ADODB.Recordset") Recordset2.ActiveConnection = MM_cro_STRING Recordset2.Source = "SELECT Contact.Con FROM Contact RIGHT OUTER JOIN CompanyName ON Contact.CN = CompanyName.CN WHERE CompanyName.CN =" + Replace(Recordset1__var, "'", "''") + "" Recordset2.CursorType = 0 Recordset2.CursorLocation = 2 Recordset2.LockType = 3 Recordset2.Open() Recordset2_numRows = 0 %> <% Dim Repeat1__numRows Repeat1__numRows = -1 Dim Repeat1__index Repeat1__index = 0 Recordset1_numRows = Recordset1_numRows + Repeat1__numRows %> <% Dim ConPosition, companyname, cn, services, ser, country, proj_no, notes, date1, con, proj
ConPosition = Recordset1.Fields.Item("ConPosition").Value companyname = Recordset1.Fields.Item("CompanyName").Value cn = Recordset1.Fields.Item("CN").Value services = Recordset1.Fields.Item("Services").Value ser = Recordset1.Fields.Item("Ser").Value country = Recordset1.Fields.Item("Country").Value proj_no = Recordset1.Fields.Item("Proj_no").Value notes = Recordset1.Fields.Item("note_ref").Value date1 = Recordset1.Fields.Item("date").Value 'if not recordset2.BOF or recordset2.EOF then con = Recordset1.Fields.Item("Con").Value 'else 'end if proj = Recordset1.Fields.Item("Proj").Value %> <script language="JavaScript"> <!-- hide from JavaScript-challenged browsers function openWindow1(url) { popupWin = window.open(url,'new_page','width=600,height=430') } function openWindow2(url) { popupWin = window.open(url,'new_page','width=550,height=590') } function openWindow3(url) { popupWin = window.open(url,'new_page','width=500,height=600,scrollbars=no') } function openWindow4(url) { popupWin = window.open(url,'new_page','width=400,height=525') } function openWindow5(url) { popupWin = window.open(url,'new_page','width=450,height=525,scrollbars=yes,toolbars=yes,menubar=yes,resizable=yes') } // done hiding --> </script> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="STYLESHEET" type="text/css" href="http://gww.chiroscience.com/css/group.css"> <script LANGUAGE="JavaScript" SRC="/javascript/group.js"></script> </head> <body bgcolor="#FFFFFF" text="#000000"> <div align="center"> <h2>CSO Database<br> <% response.write companyname %> </h2> </div> <blockquote> <div align="left"> <blockquote> <p><b>Details available :</b><br> <b>Contact Details</b> <b>:</b></p> <table width="100%" border="0"> <% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) %> <tr> <td width="34%"> <a href="con_details.asp?<% response.write "Con=" & con %>"> <% response.write ConPosition %> </a></td> <td width="66%"> <a href="con_details.asp?<% response.write "Con=" & con %>"> <% response.write services %> - <% response.write country%> </a> </td> </tr> <% Repeat1__index=Repeat1__index+1 Repeat1__numRows=Repeat1__numRows-1 Recordset1.MoveNext() Wend %> </table> <br> <p><b>Performance Data By Project</b></p> <table width="100%" border="0"> <tr> <td><a href="proj_detail.asp?<%= "proj=" & proj %>"> <% response.write proj_no%> </a></td> </tr> </table> <p><b>Notes</b></p> <table width="100%" border="0"> <tr> <td> <a href="notes.asp?<%= "note_ref=" & notes %>"> <% response.write date1%> </a> , </td> </tr> </table> <br> <br> </blockquote> </div> Add <a href="JavaScript:openWindow3('add_contact.asp?<%= "CN=" & cn %>')">Contact</a><br> Add <a href="JavaScript:openWindow1('add_notes.asp?<%= "CN=" & cn %>')">Note</a><br> Add <a href="JavaScript:openWindow2('add_prodetail.asp?<%= "CN=" & cn %>')">Performance Information</a><br> Back to listing by <a href="cn.asp">Company</a> </blockquote> <a href="default.asp">Return to the CSO homepage</a><br> </body> </html> <% Recordset1.Close() %> <% Recordset2.Close() %> ---------------------------------
thanks Paul
Paul - *bugger* said the fairy as it flew into a window |
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 30 October 2001 : 07:11:44
|
ConPosition = Recordset1.Fields.Item("ConPosition").Value companyname = Recordset1.Fields.Item("CompanyName").Value cn = Recordset1.Fields.Item("CN").Value services = Recordset1.Fields.Item("Services").Value ser = Recordset1.Fields.Item("Ser").Value country = Recordset1.Fields.Item("Country").Value proj_no = Recordset1.Fields.Item("Proj_no").Value notes = Recordset1.Fields.Item("note_ref").Value date1 = Recordset1.Fields.Item("date").Value 'if not recordset2.BOF or recordset2.EOF then con = Recordset1.Fields.Item("Con").Value 'else 'end if proj = Recordset1.Fields.Item("Proj").Value
Since you are populating these values outside the while loop, these will always be populated with the values in first record fetched from the DB.
You need to put the variables inside the loop.
GauravBhabu There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying. |
|
|