Results 1 to 2 of 2

Thread: Autonumber with prefix

  1. #1
    .NET Framework
    .NET 4.5
    Join Date
    Nov 2018
    Posts
    2
    Rep Power
    0

    Autonumber with prefix

    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

  2. #2
    .NET Framework
    .NET 4.5
    Join Date
    Apr 2011
    Posts
    1,979
    Rep Power
    154
    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •