User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 391,549 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,566 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 764 | Replies: 2
Reply
Join Date: May 2006
Posts: 2
Reputation: skhan1021 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
skhan1021 skhan1021 is offline Offline
Newbie Poster

Problem: Limiting entries into db

  #1  
May 31st, 2006
Hi everyone,

I was wondering if anyone out there knows how to limit the number of entries into a DB. I'm trying to build a page that will allow users to sign up for a class. Each class has a limit of 20 students per session. Any kind of help will be greatly appreciated.

Thanks,
SK.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Problem: Limiting entries into db

  #2  
Jun 1st, 2006
I would do two things:

on the front end when displaying the list of available classes, check the number of students already enrolled.

On the back end, use a stored procedure to add a student to a class
i would do it something like this.
sp_addStudent (@studentid int, @classid int) as
declare @count int
set @count = (select count(*) from tblClassroster where classid = @classid) 
if @count >19 
set @count = -2
else
insert into tblClassroster values (@classid, @studentid)
select (@count +1) as NumberInClass
then, after you try to insert the student you can check the returned field to see if it was successful and let the user know. (-1 means insert failed, otherwise the new number of students in the class)
Reply With Quote  
Join Date: May 2006
Posts: 2
Reputation: skhan1021 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
skhan1021 skhan1021 is offline Offline
Newbie Poster

Re: Problem: Limiting entries into db

  #3  
Jun 1st, 2006
Thanks. I will give it a shot.

I appreciate your help.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 9:12 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC