|
 |
asp_databases thread: Limiting the Adding of Records to a Database
Message #1 by "Timothy Hopkins" <thopkins@r...> on Wed, 11 Oct 2000 15:16:21 -0500
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0116_01C03396.368264C0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
I have an access database and some web pages that allow people to
register for training classes. What I would like to do is add some code
so that if they try to register for a class that ten people have already
signed up for, they will get a message telling them to register for a
different class. Does anyone have an online tutorial or code they could
share? Thanks.
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 12 Oct 2000 12:26:24 +1000
|
|
Before doing the insert, do a select to see how many records are already in
the database.
If there are ten or more, then you don't do the insert.
There is code how how to get the recordcount here:
http://www.adOpenStatic.com/faq/recordcountalternatives.asp
and
http://www.adOpenStatic.com/faq/recordcounterror.asp
Cheers
Ken
----- Original Message -----
From: "Timothy Hopkins" <thopkins@r...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, October 12, 2000 6:16 AM
Subject: [asp_databases] Limiting the Adding of Records to a Database
I have an access database and some web pages that allow people to register
for training classes. What I would like to do is add some code so that if
they try to register for a class that ten people have already signed up for,
they will get a message telling them to register for a different class.
Does anyone have an online tutorial or code they could share? Thanks.
---
Message #3 by Andy Johnson <lysaer@d...> on Wed, 11 Oct 2000 17:03:30 -0500
|
|
--------------DDC74FAB106729E9F9263B67
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
A quick and dirty suggestion (I'm sure Ken or Imar or one of the other
ASP masters have an easier and cleaner way!) is thus:
Assuming you have a primary key in your database, I'll call it
"StudentNumber" for our purposes here....
On the page called by your submission form, open a recordset pulling the
field StudentNumber WHERE StudentNumber = 9 (remember 0 is the first
number in the database)
Then, below the recordset:
IF rs.eof THEN
put your stuff to allow the sign up here
ELSE
put your notice that the class is full here
END IF
and close your recordset. :)
You might not want to use the primary key field, but this is how I
handled a similar situation in my site. :) And unlike most of my code,
it worked right off the bat!
Timothy Hopkins wrote:
> I have an access database and some web pages that allow people to
> register for training classes. What I would like to do is add some
> code so that if they try to register for a class that ten people have
> already signed up for, they will get a message telling them to
> register for a different class. Does anyone have an online tutorial
> or code they could share? Thanks.---
> FREE WEB DEVELOPMENT CODE, CONTENT, AND INSIGHTS
> IN YOUR INBOX!
> Get the latest and best HTML, XML, and JavaScript tips, tools, and
> developments from the experts. Sign up for one or more of EarthWeb?s
> FREE IT newsletters at http://www.earthweb.com today!
> lysaer@d...
> $subst('Email.Unsub')
--------------DDC74FAB106729E9F9263B67
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
A quick and dirty suggestion (I'm sure Ken or Imar or one of the other
ASP masters have an easier and cleaner way!) is thus:
<p>Assuming you have a primary key in your database, I'll call it "StudentNumber"
for our purposes here....
<p>On the page called by your submission form, open a recordset pulling
the field StudentNumber WHERE StudentNumber = 9 (remember 0 is the first
number in the database)
<p>Then, below the recordset:
<p>IF rs.eof THEN
<br>put your stuff to allow the sign up here
<br>ELSE
<br>put your notice that the class is full here
<br>END IF
<p>and close your recordset. :)
<p>You might not want to use the primary key field, but this is how I handled
a similar situation in my site. :) And unlike most of my code, it
worked right off the bat!
<p>Timothy Hopkins wrote:
<blockquote TYPE=CITE><style></style>
<font size=-1>I have an access database
and some web pages that allow people to register for training classes.
What I would like to do is add some code so that if they try to register
for a class that ten people have already signed up for, they will get a
message telling them to register for a different class. Does anyone
have an online tutorial or code they could share? Thanks.</font>---
<br>FREE WEB DEVELOPMENT CODE, CONTENT, AND INSIGHTS
<br>IN YOUR INBOX!
<br>Get the latest and best HTML, XML, and JavaScript tips, tools, and
<br>developments from the experts. Sign up for one or more of EarthWeb?s
<br>FREE IT newsletters at <A HREF="http://www.earthweb.com">http://www.earthweb.com</A> today!
<br>---
<br>
<br>To unsubscribe send a blank email to $subst('Email.Unsub')</blockquote>
</body>
</html>
--------------DDC74FAB106729E9F9263B67--
Message #4 by "peter" <ph@t...> on Thu, 12 Oct 2000 00:51:38 +0100
|
|
Try adding a field in the DB that gets incremented each time a user
registers for a class. When the form is submitted and the recordset opened
you could run some code that checks the number
ie
If rs("Num_registered") = 10 Then
Response.redirect "another_page.asp"
Else
..update record
End If
HTH
peter
|
|
 |