Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my table columns(studentID,studentName,studentRegNumber)
when I enter studentID & studentName studentRegNumber should be added automatically by considering current number of records in the table.
Examples records
StdID StdName StdRegNo
1 Nishan A1
2 Brian A2
3 Thomas A3

StdRegNumber should be added automatically like this..
Give me a help with an example...
Because I am a beginner for c#
Posted

 
Share this answer
 
v2
Looking at the sample data you have provided you need not use the studentRegNumber column in your table. You can just concatenate an A to your student ID in your query itself and get the result.

SQL
SELECT StdID,  StdName, 'A' + CAST(StdID AS VARCHAR) AS StdRegNo FROM [YourTableName]


You can use IDENTITY (Property)[^] to auto generate the student ID.
 
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