Discussion Locked

ASP Problems

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Im having a problem with this particular part of an ASP file. What im trying to do is add a cell to a table if a record exists from the second record set in correspondance to the first. It gives me a mismatch error.

<%Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=c:\windows\desktop\vdm.mdb"
strSQL = "SELECT * FROM Agreements"
Set RS = Con.Execute(strSQL)
WHILE NOT RS.EOF
%>

<%=RS( "VendorName" )%> <%=RS( "AircraftType" )%> <%=RS( "EffectiveDate" )%> <%=RS( "TerminationDate" )%> <%=RS( "AgreementType" )%> <%=RS( "CAEDoc#/Rev#" )%> <%=RS( "Restriction" )%> <%=RS( "PeriodPayment" )%> <%=RS( "TypeOfData" )%> <%=RS( "RemarkBox" )%>

<%Dim strTemp
strTemp =RS( "EffectiveDate" )
strSQL1 = "SELECT * FROM Amendments WHERE AgreeEffectiveDate = ' & strTemp & '"
Set RS1 = Con.Execute(strSQL1)
IF NOT RS1.EOF THEN
%>

Amendments <%ELSE%> No Amendments

<%END IF%>

<%
RS.MoveNext
WEND
%>

6 replies

by steved

You're just missing a couple of quotation marks. It should be:

strSQL1 = "SELECT * FROM Amendments WHERE AgreeEffectiveDate = '" & strTemp & "'"

It's an easy mistake to make. I know, because I've done it!

Steve Diamond

by bowjangles

Actually, it helped very much but i was wondering if you could help me out with one other problem relating to the same question. My IF statement is not working the way i would like it to. Im trying to do: IF the recordset contains records then Amendments ELSE No Amendments. But right now it is always printing No Amendments in the last box. Do you think you could give me a hand on this problem before i close the question and give you the points.

Thanks and Sorry for asking so many questions!

Justin

by bowjangles

Actually, it helped very much but i was wondering if you could help me out with one other problem relating to the same question. My IF statement is not working the way i would like it to. Im trying to do: IF the recordset contains records then Amendments ELSE No Amendments. But right now it is always printing No Amendments in the last box. Do you think you could give me a hand on this problem before i close the question and give you the points.

Thanks and Sorry for asking so many questions!

Justin

by steved

To debug things like this I usually put in Response.Write statements to display my SQL code before it's executed. As in:

strSQL1 = "SELECT * FROM Amendments WHERE AgreeEffectiveDate = '" & strTemp & "'"
Response.Write strSQL1

That will probably show you right away what's going wrong. My guess is that the contents of strTemp aren't exactly what you expect. Perhaps you need:

strTemp = CStr(RS( "EffectiveDate" ))

I hope this helps.

Steve Diamond

This discussion is closed to new replies.