Solved

Autogenerate IDs in VB6 and SQL

Posted on 2009-07-11
5
260 Views
Last Modified: 2012-06-27
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
Comment
Question by:al4629740
  • 3
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
ID: 24832982
>>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
 

Author Comment

by:al4629740
ID: 24832989
Sorry, I'm using SQL Express 2005

"MAX(StudentID) + 1"   Is that a VB command?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24833002
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
 

Author Comment

by:al4629740
ID: 24833010
hmm, I'm only familiar with VB.  I just use SQL to place my data in.  

Where would I put that command?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24833029
>>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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now