Question Autonumber with prefix

lional

Well-known member
Joined
Nov 29, 2018
Messages
55
Programming Experience
Beginner
Hi All
I am new to C#, in fact this is my first project.
I was given a task of writing a student administration application for my client to replace their very old app done in Access 2003.
I have developed in PHP and VB many years back but chose C# and very glad I did.
The app is progressing along very nicely but I am struggling to find the best way to do the following.
I want to auto increment student numbers, group numbers etc, and put a prefix before the numbers.
So for student numbers I want STU000001, and group numbers GRP00001.
I tried auto incrementing an ID, adding the prefix to that number and writing it back (which I am sure is not the ideal approach). My fear is that because the app has multi-users that the same number might be written back during my calculation if two users input data at the same time.

I hope I am explaining it correctly.

I don't want to be given the solution just point me in the right direction else I don't learn

Thank you, much appreciated
 
Use two columns. One for a standard AutoNumber and then a second that is calculated from the first, adding the prefix and padding the number. I'm not sure if the terminology is the same in Access but in an ADO.NET DataTable or a SQL Server column it's the expression of the column.
 
Back
Top Bottom