PDA

View Full Version : checking in bewteen values


scriptblur
11-23-2002, 12:51 AM
hi guys... please help!


i have been troubled by these two problems over the past few weeks....
1) i am using a in between sql to queries my database and if else conditions with statement to check for the values in between the two values selectd using the sql statement. however this only allows me to check the 1st values and not the values between the 1st and last selected values.
Can any one please gude me how to do?

codes:

sql = "SELECT UserID,Avail FROM Zones WHERE Week = "&Request.Form("weeks")&" AND Day = '"&Request.Form("days")&"' AND Character = '"&Request.Form("location")&"' AND Starttime AND Endtime BETWEEN "&Request.Form("times")&" AND "&Request.Form("timesno")&""
rs.Open sql, conn,1


do until rs.EOF
if (strComp(rs("Avail"),"") = 1)then
iCount=iCount - 1

else
iCount=iCount + 1
end if

rs.MoveNext
loop

if iCount <> rs.RecordCount then
'Response.Redirect "../staff/disapproved_page.asp"


2) how to clea or delete a session instaed of remove all sessions using session.abandon?

whammy
11-23-2002, 01:04 AM
Are you getting any errors? The first thing that strikes me funny is this:

AND Starttime AND Endtime BETWEEN "&Request.Form("times")&"

if you're going to do that, you need to specify each date distinctly.... that just looks like bad SQL syntax, and I'm betting you $50 that you're getting a SQL syntax error from that alone, since you did not specify any criteria for the first "AND" statement.

It does help if you post any errors you are getting (along with the code), though.

scriptblur
11-23-2002, 01:16 AM
there is no error.

the statement should be like this

Starttime AND Endtime BETWEEN "&Request.Form("times")&" AND "&Request.Form("timesno")&""

the start time = request.form("times") and endtime = request.form("timesno").. the values between these two forms are selected....

whammy
11-23-2002, 01:18 AM
If there is no error, then what is the problem? :) I haven't done a BETWEEN statement like that, but I am pretty sure that it won't work - you're trying to send two date fields (combined, which as far as I know, would not result in a valid date at all if it even worked, which I have not tested) to a function that will only check one date against the dates in the database, if I'm not mistaken.

I am REALLY surprised you aren't getting a syntax error from that alone... do you have a URL where I can see this?

I assume the error (if you really aren't receiving a syntax error, unfortunately I don't have the ability to test that syntax at the moment) is that you are getting no records returned... and the above is likely the cause. ;)

scriptblur
11-23-2002, 01:27 AM
The problem is not with the sql, it is with how to check the values bewteen the two values selected using the sql. like, i had selected values seat 1 - 5 but i need to know between the seat 1 -5 is there any seats that are available. so i need to know what is going on with seat 2,3,4 , what content is inside and is it available??

so the problem lies in the if else statement, what am i suppose to do to check for the in between values...

whammy
11-23-2002, 01:32 AM
Perhaps you should use less than and greater than...

Starttime >= '"&Request.Form("times")&"' AND Endtime <= '"&Request.Form("timesno")&"'

I'm really not sure without looking at your application, though, and seeing how you are using these variables otherwise...

scriptblur
11-23-2002, 01:48 AM
actually what u have just stated is the same result as what i have been using the in between sql statement...

do u know that can we delete or clear one session instead of all sessioins using session.abandon?

glenngv
11-25-2002, 02:59 AM
Originally posted by scriptblur
2) how to clea or delete a session instaed of remove all sessions using session.abandon?

Session.Contents.Remove("SessionName")

You may also use the integer position of the item in the collection instead of the Name argument. The numbering sequence starts at 1, not 0.