I wrote this in notepad so i have no idea if it will even compile but it should at least point you in right direction.
int seedNum = 1;
char pad = '0';
private void Main()
{
for(int i=0; i < 10; i ++)
{
Console.WriteLine("E" + seedNum.ToString().padLeft(6,pad);
seedNum += 1;
}
}
private string GenerateInvNo()
{
return seedNum.ToString().PadLeft(6, pad);
}
//-------------------------------------------------------
string ConnectionString = String.Format(@"Data Source = {0};User Id={1}; password={2}; Initial Catalog = {3};",
"DB_Server",
"DB_User",
"DB_Pass",
"DB_Name");
string query = "SELECT SeedNumber FROM YourTableName; UPDATE YourTableName SET SeedNumber = SeedNumber + 1";
SqlConnection connection = new SqlConnection(ConnectionString);
connection.Open();
SqlCommand queryCMD = new SqlCommand(query, connection);
int seedNum = (int)queryCMD.ExecuteScalar();
char pad = '0';
Console.WriteLine("E" + seedNum.ToString().padLeft(6,pad);