[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

Autogenerate IDs in VB6 and SQL

I have an SQL database and have a vb6 application.  Here is the situation:  We have students that are assigned IDs according to groups.  The ID is comprised of 5 numbers.  The first two numbers represent the Group.  Then the next 3 numbers represent the Student ID.  The Student ID increments by 1 every time there is a new student registered.

For example,  If they belong to group A, then they will be assigned 23xxx.
Group B, then 24xxx

So if a 3 new students come to group A, then it would be 23001, 23002, 23003

Do I have the ability to use Autonumber in SQL or do something in VB6, to make this happen

0
al4629740
Asked:
al4629740
  • 3
  • 2
1 Solution
 
Anthony PerkinsCommented:
>>Do I have the ability to use Autonumber in SQL or do something in VB6, to make this happen<<
If you are using MS SQL Server and are referring to the IDENTITY attribute then no, you cannot use it.  You will have to resort to doing MAX(StudentID) + 1 to get the next one and concatentate that to the Group.

If on the other hand you are using MS Access and are referring to the AutoNumber column then the answer is the same, but then you should not have posted in the MS SQL Server Zone.  :)
0
 
al4629740Author Commented:
Sorry, I'm using SQL Express 2005

"MAX(StudentID) + 1"   Is that a VB command?
0
 
Anthony PerkinsCommented:
No.  It is SQL (T-SQL to be precise) the language you use to work with your database.  It has clauses like SELECT, FROM, WHERE, GROUP BY, ORDER BY.  Do those ring a bell?
0
 
al4629740Author Commented:
hmm, I'm only familiar with VB.  I just use SQL to place my data in.  

Where would I put that command?
0
 
Anthony PerkinsCommented:
>>I just use SQL to place my data in. <<
I see.  If you cannot find anyone here prepared to tutor you, perhaps you should contract someone at www.rentacoder.com
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now