Hi...
this code may help you
Public GetMaxid()
{
con.Open();
OleDbCommand cmd1 = new OleDbCommand("Select Max(ProductGroupCode) as maxid from ProductGroup_master", con);
OleDbDataReader oledbrd1 = cmd1.ExecuteReader();
oledbrd1.Read();
if (Convert.IsDBNull(oledbrd1["maxid"]))
{
strid1 = 1;
txt_pgrpcode.Text = "1";
}
else
{
strid1 = Convert.ToInt32(oledbrd1["maxid"]) + 1;
txt_pgrpcode.Text = strid1.ToString();
}
oledbrd1.Close();
}
Hpaay Coding :) :)