Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 9th, 2004, 09:25 PM
soda jerk soda jerk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 7 soda jerk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question help with variable problem in IF statement?

hi, i'm completely stumped with this one. It is a simple test (via IF) for booking where it decides which path to follow. Or not so simple, even.. It keeps taking me to same bit. Have tried putting form value into variable. Tried rearranging various ways. The available is definatley being calculated properly and have it displayed. What can be going wrong with form? (just added 'id' there too)

Is there something missing or do i have to convert to integer format or something? The two "booked" and "places" fields are long integers, no indexing, not autoincrements or anything.

Have tried for ages with this and is holding me back from the rest of code and final few pages of my site...which is VERY frustrating. Any help would be more than great,

andy

<%
'Set the server locale
Session.LCID = 2057
%>
<html>
<body>
<h2>booking of course continued...</h2>
<%
dim cid, sid, available, placeswanted, newBooked, newPlaces
cid=Request.Cookies("currentuserID")
sid=Request.Cookies("scheduleIDbooking")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & _
Server.MapPath("DATABASE.mdb")

set rs = Server.CreateObject("ADODB.Connection")
sql = "SELECT * FROM SCHEDULE"
sql = sql & " WHERE Schedule.ScheduleID =" & sid & "; "
set rs = Conn.Execute(sql)
available =rs("Places")-rs("Booked")
if Request.Form("PlacesWanted") > available then
%>
Sorry there are not enough places currently left for this booking.
we have <%=available %> places left.
<p>cid = <%=cid %></p>
<p>sid = <%=sid %> </p>
<br />Try again or follow links below:
<form method="post" action="processBookPlaces.asp">
required places:<input type="text" name="PlacesWanted">
<input type="submit" value="book">
</form>
<a href="searchDropDown.asp">back</a>
<a href="home.asp">home</a>
<%else
newBooked = RS("Booked") + Request.Form("PlacesWanted")
newPlaces = RS("Places") - Request.Form("Places")
%>
<P>NEWBOOKED= <%=newBooked %>
<p>newPlaces= <%=newPlaces %>
<%
if err<>0 then
response.write("No update permissions!")
response.write "VBScript Errors Occured:" & "<P>"
response.write "Error Number=" & err.number & "<P>"
response.write "Error Descr.=" & err.description & "<P>"
response.write "Help Context=" & err.helpcontext & "<P>"
response.write "Help Path=" & err.helppath & "<P>"
response.write "Native Error=" & err.nativeerror & "<P>"
response.write "Source=" & err.source & "<P>"
response.write "SQLState=" & err.sqlstate & "<P>"
else
response.write("Record " & sid & " was booked!")
%>
BLAHHHHHHH....
<% end if
end if
%>
</body>
</html>

Reply With Quote
  #2  
Old April 9th, 2004, 10:06 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
try this
Code:
available = CInt(rs("Places") - rs("Booked"))

if CInt(Request.Form("PlacesWanted")) > available then

Reply With Quote
  #3  
Old April 9th, 2004, 10:15 PM
soda jerk soda jerk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 7 soda jerk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

THANKYOU!!

I couldn't have slept if that wasn't working,

cheers, andy

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > help with variable problem in IF statement?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT