private void Autonumber() { String connstring = ConfigurationManager.ConnectionStrings["Test"].ConnectionString; OleDbConnection con = new OleDbConnection(connstring); string Query = "select MAX(ReceiptNo) from Data"; OleDbCommand cd = new OleDbCommand(Query, con); { con.Open(); int count = Convert.ToInt16(cd.ExecuteScalar()) + 1; txtRecd.Text = count.ToString("00000"); txtRecd.Enabled = false; } }
var obj = cd.ExecuteScalar(); var count = (obj == DBNull.Value ? 0 : Convert.ToInt32(obj));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)