How to generate auto id like PA-01-07-2012-0001. Where 01 is the Date of a month,07 is the Month, 2012 is the year, and 0001 is auto generate id and it will be increment. after that it will check The Generated id in database.And create a new id
int id ;
sqlconnection con = new sqlconnection("your connection string");
sqlcommand cmd = new sqlcommand();
cmd.Connection = con;
cmd.CommandText = "select isnull(max(loading_record)) + 1 from testing ";
sqldatareader dr = cmd.executereader();
id = convert.toInt16( dr["loading_record"].toString());
string ID = "PA-"+DateTime.Now.Day+"-"+DateTime.Now.Month+"-"+DateTime.Now.Year+"-"+id;
i typed this code here so there are some typing errors , but hope this will solve your prob.
My C# Code is for To Autogenerate the Id Number.
Suppose There is a Id Like PA-12-08-0001.Where 12 is The Year,08 is the Month,and 0001 is the Id.If The Month will change, the Id number should be start from 0001 and increment it, Like PA-12-09-0001,PA-12-09-0002. also when year will change the month should be change and the Id will start from 0001 Like PA-13-01-0001,PA-13-01-0002. if the month and year is not changing the ID will be Increment like PA-12-08-0002,PA-12-08-0003 and so on.
I cant do This. Can You Help me in code