if.. else.. statement problem

R

Raphael Gluck

Hi

I'm fairly new to coding in asp and i'm trying to create a simple if..
else... condition
It's for asp web page, and is linked to my database, but i figured since
it's a basic question, it would belong in the General newsgroup.

All i am trying to, is, on my web page I have a table cell, that feeds off
my database.
If there's something in the database in that particular field, then I want
it to be displayed, If not, then rather the cell return a blank field, I
want a picture from another field.

<%
if rsSublisting("Specific_imagelrg") > "" then
%>
<%=rsSublisting("Specific_imagelrg")%>

<% end if %>

I've tried without luck to include an Else field, i.e if there is not
content in the above field, i want to display a different field, called
("Img_lrg")
How do i ammend the script?

Thanks

Raphael
 
B

Bob Barrows [MVP]

Raphael said:
Hi

I'm fairly new to coding in asp and i'm trying to create a simple if..
else... condition
It's for asp web page, and is linked to my database, but i figured
since it's a basic question, it would belong in the General newsgroup.

All i am trying to, is, on my web page I have a table cell, that
feeds off my database.
If there's something in the database in that particular field, then I
want it to be displayed, If not, then rather the cell return a blank
field, I want a picture from another field.
<%
if rsSublisting("Specific_imagelrg") > "" then
Response.write rsSublisting("Specific_imagelrg")
Else
Response.write rsSublisting("Img_lrg")
end if
%>

Bob Barrows
 
C

Christopher Brandsdal

Try this:

<%
if rsSublisting("Specific_imagelrg") <> "" then
%>
<%=rsSublisting("Specific_imagelrg")%>

<% end if %>
 
R

Raphael Gluck

Hi,

Thanks for that, I tried it, but it's still not working.
I get the following error,
"Item cannot be found in the collection corresponding to the requested name
or ordinal."

The Item does exist in my database,
 
B

Bob Barrows [MVP]

Obviously, it doesn't exist in your recordset.
Show us the sql statement used to generate the resultset. Hopefully you are
not using "Select *" - always explicitly list the names of the fields you
wish to retrieve.

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top