void getLoginID() { string LoginSql = "select STAFF_LOGIN_ID from STAFF_LOGIN ORDER BY STAFF_LOGIN_ID"; string LName; int LID; string format = "0000000"; SqlDataAdapter ad = new SqlDataAdapter(LoginSql, consql); DataSet ds = new DataSet(); ad.Fill(ds, "STAFF_DETAIL"); if (ds.Tables["STAFF_DETAIL"].Rows.Count > 0) { LName = ds.Tables["STAFF_DETAIL"].Rows[ds.Tables["STAFF_DETAIL"].Rows.Count - 1][0].ToString(); LID = int.Parse(LName.Substring(1, (LName.Length - 1))); loginID = "L" + ((LID + 1).ToString(format)); } else { loginID = "L0000001"; } }