<pre lang="xml">//MySqlCommand com = new MySqlCommand("SELECT isnull(Max(cast(substring(Reg_No,charindex('-',Reg_No)+1,len(Reg_No)) as int)),0)+1 FROM In_Patients", conn); MySqlCommand com = new MySqlCommand("SELECT Max(Reg_No) FROM In_Patients", conn); conn.Open(); Int32 no = Int32.Parse(com.ExecuteScalar().ToString()) + 1; conn.Close(); string RNo = "REG" + DateTime.Now.Year + DateTime.Now.ToString("MM") + DateTime.Now.ToString("dd") + "-" + String.Format("{0:000}", no); txtRegNo.Text = RNo;</pre>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)