The case that a column such as the ID column on a table will auto increment. This simply means that the next insert into the table will have an ID that is one more then the previous one and therefore all ID's will be unique.
However, if you delete a row from the table, the table will auto increment as if the row had not been deleted at all. The result is a gap in the sequence of numbers. This is normally not that much of an issue, but you may want to reset the auto increment field.
PatientNo
is primary key and here is the code what I have tried so far
private void txtincr()
{
int a;
if (textPatientNo.Text == "")
{
if (con.State == 0)
{
con.Open();
}
string Query= "select PatientNo from PatientRegistration";
SQLiteDataAdapter DataAdapter = new SQLiteDataAdapter(Query,con);
DataSet PatientDataSet = new DataSet();
DataAdapter.Fill(PatientDataSet);
if (PatientDataSet.Tables[0].Rows.Count != 0)
{
a = PatientDataSet.Tables[0].Rows.Count;
a = a + 1;
textPatientNo.Text = Convert.ToString(a);
textPatientName.Focus();
}
else
{
textPatientNo.Text = "1";
textPatientName.Focus();
}
con.Close();
}
}