hi guys
im having trouble with my asp if else loop. I'm very close but not 100% quite there yet.
in my sql server table I have flight routes which consist of prices, dates, months - I am then pulling this out using classic asp on my site
what i want is
1. if all 5 prices are NULL to not display anything.
2. and only display rows that have a price. e.g I wouldnt want to display row 1 & 4 by looking at the same data below. so in the sample data's case just to skip row 1 and row 4.
sample data - GATWICK to TORONTO
-
Price Flight Date/s
-
£
-
£219 Dec 7
-
£149 Jan 13, 14, 16, 20, 21, 23
-
£179 Feb 3, 4, 6, 10, 11, 13, 17, 18, 24, 25, 27
-
£
in my asp logic I can skip the first row, display the next 3 rows and skip the 4th row - see below - <%
-
'DISPLAY PRICES
-
DIM objConn1
-
Set objConn1 = Server.CreateObject("ADODB.Connection")
-
objConn1.ConnectionString = "Provider=SQLOLEDB;Data Source=IPREMOVED" & _
-
"Initial Catalog=DBNAMEREMOVED;User ID=IDREMOVED;Password=PASSWORDREMOVED"
-
objConn1.Open
-
-
DIM FLIGHTROUTE1
-
FLIGHTROUTE1 = "SELECT * FROM UK_Specials WHERE ID = 1"
-
-
DIM objRS1
-
Set objRS1 = Server.CreateObject("ADODB.Recordset")
-
objRS1.Open FLIGHTROUTE1, objConn1
-
-
'retreive 1st row/date band routes
-
If (IsNull(objRS1("Price_Band_1"))) Then
-
Response.Write ""
-
Else
-
Response.Write "<div id=""outboundroute"">" & objRS1("Anchor_Tag")
-
Response.Write "<fieldset class=""fieldsetspecialpricebox"">" & vbCrLf
-
Response.Write "<legend>" & vbCrLf & "<span class=""specialtitlesmall"">" & objRS1("Flight_Route") & "</span>" & vbCrLf & "</legend>" & vbCrLf
-
Response.Write "<table align=center cellpadding=0 cellspacing=0 class=""specialpricetable"">" & vbCrLf
-
Response.Write "<tr><td class=""dateheadertd"">Flight Date/s</td></tr>" & vbCrLf
-
Response.Write "<tr><td height=10> </td></tr>" & vbCrLf
-
-
'write your table content
-
Response.Write "<tr><td class=""datetd""><span class=""monthspan"">" & objRS1("Month_Band_1") & " </span>" & objRS1("Date_Band_1") & "</td></tr>"
-
End If
-
-
'retreive 2nd row/date band routes
-
If (IsNull(objRS1("Price_Band_2"))) Then
-
Response.Write ""
-
-
Else
-
Response.Write "<tr><td class=""datetd""><span class=""monthspan"">" & objRS1("Month_Band_2") & " </span>" & objRS1("Date_Band_2") & "</td></tr>"
-
End If
-
-
'retreive 3rd row/date band routes
-
If (IsNull(objRS1("Price_Band_3"))) Then
-
Response.Write ""
-
-
Else
-
Response.Write "<tr><td class=""datetd""><span class=""monthspan"">" & objRS1("Month_Band_3") & " </span>" & objRS1("Date_Band_3") & "</td></tr>"
-
End If
-
-
'retreive 4th row/date band routes
-
If (IsNull(objRS1("Price_Band_4"))) Then
-
Response.Write ""
-
-
Else
-
Response.Write "<tr><td class=""datetd""><span class=""monthspan"">" & objRS1("Month_Band_4") & " </span>" & objRS1("Date_Band_4") & "</td></tr>"
-
End If
-
-
'retreive 5th row/date band routes
-
If (IsNull(objRS1("Price_Band_5"))) Then
-
Response.Write ""
-
-
Else
-
Response.Write "<tr><td class=""datetd""><span class=""monthspan"">" & objRS1("Month_Band_5") & " </span>" & objRS1("Date_Band_5") & "</td></tr>"
-
End If
-
-
Response.Write "</tr></table></fieldset>"
-
Response.Write "</div>"
-
-
objRS1.Close
-
Set objRS1 = Nothing
-
objConn1.Close
-
Set objConn1 = Nothing
-
%>
but to cover all angles i think i need the first if statement to check if price band 1 - 5 are empty then do nothing - otherwise build table header and proceed..
but i dont think this is the way to do a if is null check on multiple recordset values??? - 'check to see if there are any prices
-
If (IsNull(objRS1("Price_Band_1" & "Price_Band_2" & "Price_Band_3" & "Price_Band_4" & "Price_Band_5"))) Then
-
Response.Write ""
-
-
Else
-
'build table header
-
Response.Write "<div id=""outboundroute"">" & objRS1("Anchor_Tag")
-
Response.Write "<fieldset class=""fieldsetspecialpricebox"">" & vbCrLf
-
Response.Write "<legend>" & vbCrLf & "<span class=""specialtitlesmall"">" & objRS1("Flight_Route") & "</span>" & vbCrLf & "</legend>" & vbCrLf
-
Response.Write "<table align=center cellpadding=0 cellspacing=0 class=""specialpricetable"">" & vbCrLf
-
Response.Write "<tr><td class=""dateheadertd"">Flight Date/s</td></tr>" & vbCrLf
-
Response.Write "<tr><td height=10> </td></tr>" & vbCrLf
-
-
'retreive 1st row/date band routes
-
If (IsNull(objRS1("Price_Band_1"))) Then
-
Response.Write ""
-
Else
-
-
and so on...... etc%>
please advise
thanks in advance
Omar.
3 4075
If I'm understanding correctly, I would just change the SQL statement to only pull records that do not have a null or empty value. Then after opening the recordset you can see if the recordset is empty. - If objRS1.EOF Then
-
'do nothing
-
Else
-
'your code here
-
End If
I've been working on this problem since friday and managed to come up with a solution. took me ages to work it out though
this is how I adapted my if statement to check for null/not null on multiple values which works great; -
If (NOT IsNull(objRSLGWYUL("Price_Band_1"))) OR (NOT IsNull(objRSLGWYUL("Price_Band_2"))) OR (NOT IsNull(objRSLGWYUL("Price_Band_3"))) OR (NOT IsNull(objRSLGWYUL("Price_Band_4"))) OR (NOT IsNull(objRSLGWYUL("Price_Band_5"))) Then
-
I now have another problem. but I will try fixing it if not I will open a new thread.
thanks
Omar.
- If not IsNull("COL1") or trim(COL1) = "" OR not IsNull("COL2") or trim(COL2) = "" ..... then
-
-
Else
-
-
End If
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ptrlks |
last post by:
Hi again,
the problem is in this code:ElseIf Right(rsBokad("aktivitet"),
3) = "Cup" Then
dStartDate = Cdate(rsBokad("startDatum"))
dEndDate = Cdate(rsBokad("endDatum"))
|
by: John F. |
last post by:
Hi all,
I'm searching fulltime for days now, and I don't find the solution, so I'm
thinking this is more a bug :(
If i use following code in form&subforms:
|
by: jstaggs39 |
last post by:
I have a form that requires a start date and an end date as input for
the parameters then runs the form which open queries which are designed
to populate certain tables. As it stands now, i can...
|
by: /2ez|n |
last post by:
I found the answer,
but thanks for all the
help!
For my c++ class I have to make a small win32 console program that
calculates body mass index. The user will enter in a their first and...
|
by: JDK721 |
last post by:
I need help with writing a loop that prints 1-20 to the screen but skips 15, 16, and 17.
I know how to write a for loop that prints any number range, such as 5-200 1-20 etc. But I don't know how...
|
by: chiefs |
last post by:
I'm a beginner in C++!!
#1-Dont know how to loop end when int q(entered); int q is a very large # when ran: printf("\n%i#of Questions\n", q);
#2-is the line "how many questions Right"?...
|
by: stressedstudent |
last post by:
I dont know where I am going wrong so I dont know which part to post, this is what I have, can anyone help me figure out where I am going wrong? THanks for any and all help.
// into to c++
//...
|
by: zalery |
last post by:
so i'm trying to set up this exponents loop, keep in mind this is my first year in computer science so my knowledge of script is somewhat minimal. basically this assignment (or at least part of it)...
|
by: kenneth6 |
last post by:
#include <iostream>
using namespace std;
int main()
{
char firstname;
char finalFirstname;
cout << "Enter your first name: ";
int num = 0;
|
by: Thekid |
last post by:
I need help writing a loop for this.
image = ImageGrab.grab((0,0,800,800))
box = (100,100,400,400)
im = image.crop(box)
im1 = im.save("screen.jpg")
# at this point I need to rotate the image...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |