PDA

View Full Version : Annoying error!


Shade
05-16-2003, 04:20 PM
I have one page, called submenu2.asp that has the code below to call a picture in the field PIC which corrolates to the field SUB_MENU_CODE. The variable "name2" is a name of a submenu, "Breakfast Items", "Breakfast Action Stations", etc... The vairbale "num" is a unique number I have assigned each name, so that I can have more than one JS link per page.

function viewpic(){
var popurl="picture.asp?pic=<%=pic%>"
winpops=window.open(popurl,"","width=400,height=338,")
}

So it has the link for this picture for each catagory of items.

<a href="javascript:viewpic(<%=num%>)"><%=name2%></a>


This is the code on the above link's picture.asp

<%
Set picRS = Server.CreateObject( "ADODB.Recordset" )
picRS.ActiveConnection = objConn
sqlString = "SELECT PIC FROM SUB_MENU_CODES WHERE SUB_MENU_CODE = '"& sub_menu_code &"'"
picRS.Open sqlString, objConn, adOpenForwardOnly, adLockReadOnly, adCmdText
pic=picRS("PIC")
' if picRS("PIC") <> "" then
' pic = picRS("PIC")
' end if
%>
<IMG SRC="images/<%=pic%>" border="0">

I keep getting an error on line 42, which is the one I have highlighted.

Link to the site. (http://www.vitoscatering.com/submenu2.asp?menu=001A&submenu=001B)

Roy Sinclair
05-16-2003, 05:00 PM
Your SQL query didn't return any records, that's why you get the error. Perhaps if you set the value of sub_menu_code before executing the sql?

Morgoth
05-16-2003, 11:09 PM
That's what I would of said, Roy Sinclair.

It's also a good idea to make an if statement saying, that if you don't have anything selected for a picture, skip trying to make a picture get displayed with the pic value = False...