473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Event Registration form

Hello all, I am having a lot of problems trying to add + 1 to my listed code. The form accepts registrations from an individual and their guest. How could I add the count for guest in the code below. Seriously, stuck on this please help...
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. dim r, sqlCount, sqlList, tableNr
  3. tableNr = Cint("1") 'use request("tableNr") to have the tableNr passed in as part of a querystring
  4. %>
  5.  
  6.  
  7. <p>People booked on Table&nbsp;<%=tableNr%></p>
  8. <p>
  9.  
  10. <%
  11.  
  12. 'create recordset object
  13. Set r = Server.CreateObject("ADODB.Recordset")
  14. r.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("seating.mdb")
  15.  
  16. 'Construct SQLCount statement 
  17. SQLCount = "SELECT count(Table1.tableNo) AS CountOftableNo FROM Table1 WHERE Table1.tableNo=" & tableNr & "" 
  18.  
  19.  
  20. SQLList = "SELECT firstname, lastname, guestname FROM Table1 WHERE Table1.tableNo=" & tableNr & ""
  21.  
  22. 'execute SQLCount statement
  23. r.Open sqlCount
  24.  
  25. dim SeatsBooked, SeatsLeft
  26.  
  27. SeatsBooked = r("CountoftableNo")
  28. SeatsLeft = 10 -  SeatsBooked 
  29.  
  30. response.write "There are "
  31. response.write SeatsBooked
  32. response.write " people sitting at this table."
  33. response.write "<br>"
  34. response.write "<br>"
  35. response.write r("CountoftableNo")
  36.  
  37. r.close
  38. 'Set r = NOTHING
  39. 'execute SQLList statement
  40. r.Open sqlList
  41. While NOT r.EOF
  42. response.write r("firstname")
  43. response.write "&nbsp;"
  44. response.write r("lastname")
  45. response.write "<br>"
  46. response.write r("guestname")
  47. r.MoveNext
  48. WEND
  49. r.close
  50. Set r = NOTHING
  51.  
  52.  
  53. %>
  54.  
  55.  
  56. <p>
  57.  
  58. <% IF SeatsBooked = 10 THEN %>
  59.  
  60. This table is fully booked. Please try another table.
  61.  
  62. <%ELSE%>
  63.  
  64. There are <%=SeatsLeft%> available seats at this table. To join this table complete the form below.
  65. </p>
  66.  
  67.  
  68.  
  69. <%END IF%>
Aug 26 '07 #1
2 1545
jhardman
3,406 Expert 2GB
So a given user may or may not have a guest? The most straight-forward method to solve this problem is to give guests their own entry in the db.

The second easiest approach (requires no change to the db, but more coding) is to open another recordset. What does the guest field say if the user doesn't have a guest? maybe "none" or null. you open the same recordset but with an additional statement in the where clause - "AND guestName <> 'none'" the count in this recordset is the number of users who have a guest. Add this count to the count in your other recordset for the total number of seats taken.

The most awkward way to solve this problem is the old-fashioned way: count (loop through the data and count whether there is a guest). But of course this isn't very elegant.

Let me know if this helps.

Jared
Aug 28 '07 #2
markrawlingson
346 Expert 100+
Correct me if i'm misunderstanding..

You have a registration form where a registrant can sign up for an event, and they may or may not have a guest. If they do have a guest, it is kept in the same record as the person who has registered at that particular table. The problem you are having is you cannot count the guest because the guest is contained within the same record as the registrant. Correct?

The most efficient and easiet way to do this would be to keep the guest as a separate record from the registrant him/her self. You can do this by, as suggested above, having the guest come and register him/herself - OR you could insert the guest as a NEW record when you call your insert statement.

So if a person comes to register and enters a guest - you'd update the record as such..

rs.addnew
rs("firstname") = sFirstName
rs("lastname") = sLastName
rs.Update

rs.AddNew
rs("firstname") = sGuestName
rs("lastname")= sGuestLastName
rs.Update

Then it will count correctly.

However, if you wish to keep it the way you've already got, the only plausible way would be to loop through the recordset, counting +2 for each record that has a guest attached to it, and +1 for each record that does not have a guest attached to it... and then move back to the first record of course.

do until rs.eof
If Not IsNull(rs("GuestName")) Then
regcount = regcount + 2
Else
regCount = regCount+1
end if
rs.movenext
loop
rs.movefirst

Hope this helps.
Aug 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: karolina | last post by:
Hi, I am making a small registration form about cars in three steps. The first step is to fill in member data. After filled out the member data hit "next" and enter car information. Hit "next"...
3
by: Tim Thomas | last post by:
Hi, I am very new to .NET and am in the process of building my first web application. I will briefly describe what i am trying to achieve: I have a system where suppliers register their...
0
by: Francois Malgreve | last post by:
Hi all, I have a more or less complex form with a few buttons and a few input fields. One of my my input field ( a TextBox) I have an event handler for the TextChanged event. What I want is...
0
by: Jitu | last post by:
<form runat=server id=myform> <AT_COMMON:SitePage id="DefaultPage" runAt="Server"> <itemTemplate> <AT:UsersRegistration id="Registration" RunAt="Server" UserFormName="Users/Users/UserForm.ascx"...
2
by: blantz | last post by:
I am fairly new with ASP.NET and have been asked to make a Registration page in VB using an Access database which includes company info attendee info which sessions they are attending how many...
1
by: Joe Wright | last post by:
Hello, I have a client/server application that needs to show forms depending on what is received. The problem is that my Client class that handles all of the sending and receiving of data raises...
3
by: Kevin | last post by:
We have a base class that is responsible for creating the navigation and look and feel of our applications. So all our web pages inherit from this base page so they don't have to worry about the...
0
by: Wayne Smith | last post by:
I've taken the following code from a developers web site which should allow a user to register and receive an email message with a link to activate their account, but when I click the link on my...
1
by: gbezas | last post by:
Hi All, I have added an event handler to redirect form.submit() to a newSubmit() method that I have defined (which does some additional processing before submitting the form). Additionally I...
1
by: stmfc | last post by:
hi, for an event handling mechanism, we need an event object. (the object where the event actually occur) and we need an event handler, and we need a registration of the event handler to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.