Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
2.65/5 (3 votes)
See more: , +
SQL
Suppose I have unique ID kvk0001

where kvk is fixed 0001 is increment by one such as:
kvk0001,kvk0002,kvk0003.......

And unique ID kvk0001 is same id for each table of registration.


how to develop a code for above case in C# & ASP.NET ?
Posted
Updated 13-Mar-14 16:29pm
v4
Comments
[no name] 13-Sep-13 10:45am    
"code for above case in C#", if you are unable to add 1 to an integer and concatenate a string then you really should be picking a book on basic C# programming and working through it.

 
Share this answer
 
Comments
Thanks7872 11-Sep-13 8:23am    
Great one..! +5
Anuja Pawar Indore 12-Sep-13 3:03am    
Thanks Rohan
Thanks7872 12-Sep-13 3:05am    
I found approximately 7 to 8 similar type of questions in last 24 hours.
Anuja Pawar Indore 12-Sep-13 3:13am    
Agree, its very common. But rather than searching everyone needs it to be served
Thanks7872 12-Sep-13 3:14am    
:-)
adding a prefix/suffix. Something like this should work:

1 - Add an IDENTITY field which will be auto-incremented
2 - Add a calculated field in the table with the definition of:

[InvoiceNo] AS ('AS' + RIGHT(('000000000' + CAST(idfield AS varchar(9))), 9) + 'FAK')

This will give you invoiceno in the format of:

AS000000001FAK
AS000000002FAK
...
AS000995481FAK
 
Share this answer
 

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