I want to reset increment value when i delete value from database table . Pno is primary key and here is the code what i have tried so far
private void txtincr()
{
int a;
if (txtPno.Text == "")
{
if (con.State == 0)
{
con.Open();
}
string str = "select Pno from Patient_Reg";
SQLiteDataAdapter da = new SQLiteDataAdapter(str, con);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count != 0)
{
a = ds.Tables[0].Rows.Count;
a = a + 1;
txtPno.Text = Convert.ToString(a);
txtpname.Focus();
}
else
{
txtPno.Text = "1";
txtpname.Focus();
}
con.Close();
}
}
Aucun commentaire:
Enregistrer un commentaire