forum

home / developersection / forums / how achieve generative one have regularity id

how achieve generative one have regularity id

Kenny Tangnde 3214 12-Sep-2011

hi all,

 how achieve  generative one  have regularity id.

my code mind is below:

 private void btnNewTranNum_Click(object sender, EventArgs e)
      {
          string constring = @"server=PC-aken\MYSQL;initial catalog=MySql; integrated security=SSPI; ";
          SqlCommand cmd = new SqlCommand();
          cmd.CommandText = "SELECT *FROM TransportNum";
          SqlConnection sqlcon = new SqlConnection(constring);
          cmd.Connection = sqlcon;
          sqlcon.Open();
          int k = Convert.ToInt32(cmd.ExecuteScalar());
          cmd.CommandText = "UPDATE TransportNum SET TransportNum=TransportNum+1";
          cmd.ExecuteNonQuery();
         
         
          DateTime d = DateTime.Now;
          string todaydate = d.ToString("yyyymmdd");
          txtNum.Text = todaydate.ToString() + k.ToString();//txtNum.Text=2011091222

       //although can achieve me desire,but this Algorithm is not good ,all have better algorithm?

     /*

        current date(20110912) and database record number(22)

       as result is:2011091222

      

    */


      }

thanks in advance.


c# c# 
Updated on 14-Sep-2011
Can you answer this question?

Answer

5 Answers

Liked By