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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exception occurred error

Status
Not open for further replies.

Airpan

Technical User
Jun 14, 2005
172
0
0
US
When I run this code locally it queries the database for information and displays it, but for whatever reason, displays an error (below the information it displays) which reads,
Exception occurred.
sideloader.asp, line 75


Line 75 is:
Code:
Response.Write("<img src=" & Rec1("PIC") & " border=0>")

Here is the connection code:
Code:
Dim oConn, Rec1, Rec2, sConn, sFilePath

   	Set oConn = Server.CreateObject("ADODB.Connection")
   	sFilePath = Server.MapPath("db/logins.mdb")
   	sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sFilePath & ";"
   	oConn.Open sConn

	Set Rec1 = oConn.Execute("SELECT * FROM inventory WHERE TYPE='Sideloader'")
	Set Rec2 = oConn.Execute("SELECT * FROM logins")
	Do While Not Rec1.EOF
	Do While Not Rec2.EOF

Here is the "display it" code:
Code:
Response.Write("<table width=100% height=135 border=0 align=center cellpadding=0 cellspacing=0>")
Response.Write("<tr>")
Response.Write("<td width=137 height=30 align=left valign=bottom background=images/bar.gif>Photos</td>")
Response.Write("<td width=275 align=left valign=bottom background=images/bar.gif>Vehicle Information</td>")
Response.Write("<td width=67 align=left valign=bottom background=images/bar.gif>Mileage</td>")
Response.Write("<td width=71 align=left valign=bottom background=images/bar.gif>Price</td>")
Response.Write("</tr>")
Response.Write("<tr>")
Response.Write("<td width=80 align=center valign=middle>")
Response.Write("<img src=" & Rec1("PIC") & " border=0>")
Response.Write("</td>")
Response.Write("<td width=450 align=left valign=top>")
Response.Write(Rec1("YR"))
Response.Write(", &nbsp;")
Response.Write(Rec1("MK"))
Response.Write(", &nbsp;")
Response.Write(Rec1("MD"))
Response.Write(", &nbsp;")
Response.Write("<b>Stock #: </b>")
Response.Write(Rec1("STK"))
Response.Write("<br>")
Response.Write("<img src=images/phone.gif>")
Response.Write(Rec2("Phone"))
Response.Write(", &nbsp;")
Response.Write(Rec2("CustName"))
Response.Write(", &nbsp;")
Response.Write(Rec2("Address"))
Response.Write("<br>")
Response.Write ("Email Dealer: ")
Response.Write(Rec2("email"))  
Response.Write("</td>")
Response.Write("<td width=60 align=center valign=right>")
Response.Write(Rec1("MILES"))
Response.Write("</td>")
Response.Write("<td width=60 align=center valign=right>$")
Response.Write(Rec1("Price"))
Response.Write("</td>")
Response.Write("</tr>")
Response.Write("</table>")
Rec1.MoveNext
Rec2.MoveNext

Loop
Loop
oConn.Close

~E
 
Do you have a value for the recordset? It would seem the error may be there is nothing in the recordset...

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
This is sort of a wild guess but I see that the field is named PIC and it is being used as the source for an image tag...

Is it possible that this database field contains binary image data rather than a URL of an image?
 
In the PIC field of the database I have the following path: trucks/image.jpg. As far as binary image - I do not have any images in the database. It contains only the url.

~E
 
Hmm... Did you try to enclose the src within quotes?

Code:
Response.Write("<img src=[COLOR=red]'[/color]" & Rec1("PIC") & "[COLOR=red]'[/color] border=0>")
or
Code:
Response.Write("<img src=[COLOR=red]""[/color]" & Rec1("PIC") & "[COLOR=red]""[/color] border=0>")

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Chopstik,
I went into the DB to be sure that there wasn't something duplicative causing a problem and didn't see anything. However, I did note that the page is trying to display two sideloaders and there is only one sideloader in the database.

~E
 
I also tried your code and it still generates and error.

~E
 
Chopstik,
I tried this hoping it would generate something else to go on...
I commented out line 75 ( the line calling the PIC recordset) and it generated this error:

ADODB.Field error '80020009'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
sideloader.asp, line 0


~E
 
The Access driver will throw an execption when the field name you are trying to read does not exist in the recordset


and of course you have the problem of trying to loop two recordsets and using RS.MoveNext on BOTH recordsets in the inner loop.



Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Chris,
If you think the code is written incorrectly, how should it be written?

~E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top