Click here to Skip to main content
16,016,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I Have a table
-tblItem (id,name,category)
ID | Name | Category |
001 Books Paper
002 Pen Writer
003 Pencel Writer

and i want to generate it like that
ID | Name | Category
PD-001PP Book Paper
PD-002WR Pen Writer
PD-003WR Pencel Writer
Posted

1 solution

You can set the ID column to a primary key with identity turned off.

Then, whenever you insert a new record through VB
1) get the last ID.
2) parse the string to get the number at the right for e.g. 001 etc
3) increment it by 1
4) append the product code to this number for e.g. 'PD-' + 004
5) insert the new row
 
Share this answer
 
v2
Comments
Nirav Prabtani 18-Jul-14 3:17am    
my 5+
Abhinav S 18-Jul-14 3:19am    
Thank you Nirav.
phanithly 18-Jul-14 3:43am    
Thank for your answer i'll try this way

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