Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to auto genrate student registration no in textbox according to selected class from dropdownlist in such format..classname/registrationno/2014 how we can do
Posted

In every DB server auto increment feature exist.

In SQL Server you have IDENTITY.
In Oracle you have SEQUENCE.

So you can use any of the feature to achieve this.
 
Share this answer
 
SQL
something like below,

registrationNumber.Text=ClassnameDropDownList.SelectedValue+"/"+(Query database to get no.of students in the class)+"/"+DateTime.Now.Year


C#
Database Query should be something like below

select count(S.No) from Student where classname='ABC' and year='2014'
 
Share this answer
 
v3
For id generation acc to client then dont use database id generation
becse it will create itself format and also it will create problem in deleting .
For this use class and see below
your database query may be like this
select isnull(max(S.No),0) + 1 from Student where classname='ABC' and year='2014'
and registrationNumber.Text=ClassnameDropDownList.SelectedValue+"/"+(Query)+"/"+ DateTime.Now.Year
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900