Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in respons.write code

Status
Not open for further replies.

ccampbell

Programmer
Aug 16, 2001
201
US
I the following code on my ASP page that will not run. I have verified that the connection opens correctly but my response.write function throw different errors. Here is the code

QUERY:
"select vehicle.id_number, vehicle.unit_number, location, date, time from temp_table right outer join vehicle on (temp_table.id_number = vehicle.id_number) where location = '" & Request.Form("searchvalue") & "' AND unit_number = '" & Request.Form("searchvalue2") & "';"

this works correctly, I have tested in in SQL Query manager as well. Now for the part that does not work

<%
while not rs.EOF
Response.write(&quot;<tr><td>&quot; & rs(vehicle.id_number) & &quot;</td><td>&quot; & rs(vehicle.unit_number) & &quot;</td><td>&quot; & rs(location) & &quot;</td><td>&quot; & rs(date) & &quot;</td><td>&quot; & rs(time) & &quot;</td></tr>&quot;)
rs.MoveNext
wend
%>

this give me the error
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/WebSite/trackingresults.asp, line 210 (this line is the Response.Write line)

If I change the response.write line to
<%
while not rs.EOF
Response.write(&quot;<tr><td>&quot; & rs(id_number) & &quot;</td><td>&quot; & rs(unit_number) & &quot;</td><td>&quot; & rs(location) & &quot;</td><td>&quot; & rs(date) & &quot;</td><td>&quot; & rs(time) & &quot;</td></tr>&quot;)
rs.MoveNext
wend
%>

This gives me the error message
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/WebSite/trackingresults.asp, line 210

If I change the response.write line to
<%
while not rs.EOF
Response.write(&quot;<tr><td>&quot; & id_number & &quot;</td><td>&quot; & unit_number & &quot;</td><td>&quot; & location & &quot;</td><td>&quot; & date & &quot;</td><td>&quot; & time & &quot;</td></tr>&quot;)
rs.MoveNext
wend
%>

This executes fine but then it just prints out blanks and no data. Please help me with this problem. How can I get it to print out valid data to a table.


 
Nevermind, I just fixed the problem. I needed quotes
rs(&quot;value&quot;).
I was missing the quotes
 
If you had used Option Explicit it would have told you that variable vehicle was not defined. You can not use recordset field names in code without enclosing them in &quot;&quot;. I just substituted to the relative field number.

Response.write(&quot;<tr><td>&quot; & rs(0) & &quot;</td><td>&quot; & rs(1) & &quot;</td><td>&quot; & rs(2) & &quot;</td><td>&quot; & rs(3) & &quot;</td><td>&quot; & rs(4) & &quot;</td></tr>&quot;)
Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
When using fields in a recordset the correct syntax is &quot;RS(&quot;Field Name&quot;). In your second example rs(id_number) should read rs(&quot;id_number&quot;).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top