Click here to Skip to main content
15,920,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table called ProfileMaster, in that many columns are there. I added ProfileId as auto increment and set it as primary key.

And now I have another column called AdvisorCode, here I want to increment AdvisorCode automatically when new profile is created. AdvisorCode will be starting like this

"V3W000000"
"V3W000001"
"V3W000002"
"V3W000003"
"V3W000004"
"V3W000005"
...........
...........
...........
...........
........... SO ON

So Can anyone help me please?
Posted
Updated 10-Sep-13 21:20pm
v2

Check the link..and change according to your need..

http://forums.asp.net/t/1608233.aspx[^]
 
Share this answer
 
Make a function for genrating id

C#
void Id()
       {
           string query = "select * from POS1 where Warehouse='" + Warehouse.Text + "' order by No";
           DataTable dt = conn.fill(query);
           string id = ""; int ID = 0;
           if (dt.Rows.Count > 0)
           {
               int ctr = dt.Rows.Count - 1;
               id = dt.Rows[ctr]["NO"].ToString();
               ID = int.Parse(id);
               ID++;
               string no =V3W000.ToUpper();
               id = no + "/" + ID;
           }
           else
           {
               string no = V3W000.ToUpper();
               ID = 1;
               id = no+ "/" + ID;
           }
           TextBox.Text = id;

   }
 
Share this answer
 
Comments
Aboobakkar Siddeq D U 11-Sep-13 3:33am    
I want to set it in SQL Server itself. How can I?
 
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