|
 |
sql_language thread: repeats 2 records and shows around 8 records..
Message #1 by oranee@y... on Fri, 9 Feb 2001 00:32:22
|
|
This kind of 'repeating rows' problems are very likely caused by missing
joins between tables. In your case, I didn't see any join operation
between tblSelfInfo and tblLookFor in your statement.
I could be wrong, why don't you write out the SQL statement you
generated? I am sure you will find the problem there.
HTH
Bo
> <% @Language = vbscript %>
> <%
>
> intRelation = Request.Form("qrelation")
> sqlget = " tblLookfor.RelationID = " & intrelation
>
> strGender = Request.Form("qGender")
> sqlget = sqlget & " AND tblSelfinfo.Gender = '" & strGender & "'"
>
> 'Problem here==>AGE
> intAge1 = Request.Form("qtage1")
> intAge2 = Request.Form("qtage2")
>
> 'sqlget = sqlget & " AND CAST( (( DateDiff("d",tblSelfInfo.BirthD,Now
()))/365.25) AS Int ) >= " & intAge1 & " AND CAST( ( (DateDiff
("d",tblSelfInfo.BirthD,Now())) /365.25 ) AS Int) <= " & intAge2
> sqlget = sqlget & " AND (((DateDiff("d",[tblSelfInfo].[BirthD],Now
()))/365.25) >= " & intAge1 & " AND ((DateDiff("d",[tblSelfInfo].
[BirthD],Now()))/365.25)<= " & intAge2 & ")"
>
> set oConn = Server.CreateObject("ADODB.connection")
> oConn.open "Friends"
> sqltext = "SELECT * from tblSelfInfo, tblLookFor "
> sqltext = sqltext & " WHERE tblSelfInfo.FriendID <> " & Session
("FriendID") & " and " & sqlget
> set oRsFriend = oConn.execute(sqltext)
>
> 'Response.Write "-------" & sqlget
> Response.Write("<table border=1 cellpadding=1 cellspacing=1 style='font-
family:arial; font-size:10pt;'>")
> Response.Write("<tr bgcolor=black style='color:white;'><td>First
Name</td>")
> Response.Write("<td>Last Name</td>")
> Response.Write("<td><b>Detail</b></td></tr>")
>
> sColor = "white"
>
> Do While NOT oRsFriend.EOF
> If sColor = "silver" Then
> sColor = "white"
> Else
> sColor = "silver"
> End If
>
> Response.Write("<tr bgcolor='" & sColor & "'>")
> Response.Write("<td>" & oRsFriend("FName").Value & "</td>")
> Response.Write("<td>" & oRsFriend("LName").Value & "</td>")
> 'Response.Write("<td>" & oRS("").Value & "</td></tr>")
>
> oRsFriend.MoveNext
> Loop
> Response.Write("</table><br><br>")
> oConn.Close
> Set oRsFriend = Nothing
> Set oConn = Nothing
>
> %>
>
> ///I got the output repeating 4 time!!
> EX..suppose it should show only 2 records but it repeats these 2 records
and shows around 8 records..
> What did I do wrong???
> Please help!!
> Thanks very much in advance
|
|
 |