Click here to Skip to main content
14,981,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to Insert the admission form of a student.
When i insert this from at that click this admission no is need to be increesed..
For different insertion it values will be mustly increesed...

For Example 1st form insertion click, AdmNo is: Adm0001
2nd form insertion click, AdmNo is: Adm0002
3rd form insertion click, AdmNo is: Adm0003......
Like this.
Any one Pls help me
Nilesh Patil Kolhapur 26-Apr-12 6:06am
increased from database or program?
Mohamed Mitwalli 26-Apr-12 6:46am
hi is the digit number will always be 4 digit like 0001 , 0002 and so on ?
shwetha1 26-Apr-12 7:38am
Increased from program that will be stored on that database as Record by record
shwetha1 26-Apr-12 7:39am
Its Not Necessary to number as 4 digits but its must to increment for every submission

For the requirement specified in the question, I think a public variable for AdmnNo can be declared and its value is incremented in each click of the button as shown below, and the AdmId is generated using string.Format
int AdmnNo = 0;
//Within the click event of the button
string AdmnId = string.Format("Adm{0:0000}",++AdmnNo);
Console.WriteLine (AdmnId);
[no name] 26-Apr-12 7:08am
VJ Reddy 26-Apr-12 7:08am
Thank you, Wes.
Vipin_Arora 26-Apr-12 7:10am
VJ Reddy 26-Apr-12 7:14am
Thank you, Vipin.
shwetha1 26-Apr-12 7:37am
Thanks for ur answer but for every insertion it will take Admno:AdmNo0001 only...
VJ Reddy 26-Apr-12 8:47am
Please see the scope of AdmnNo. If the AdmnNo is declared within the click event of the Button then each time the Button is clicked AdmnNo will be initialized to 0. So, AdmnNo should have class level scope, i.e, AdmnNo should a Field of the class or still better declare it as the static field of the class.
you have to set in your table
Set the Field AdmNo as Primary Key and

set Identity Specification as Yes
IsIdentity as Yes
Increment By 1

the above can see by right clicking the table->design

hope this help you
shwetha1 26-Apr-12 6:31am
Thanks for u r Reply But I dont need to set any Identity Specification for my Table Is this possible?

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