I use this code to determine the next ID of an article. So if I were to add a new article to my database then it would recieve that ID.
But sometimes when I delete an article then the ID number is wrong when sometimes it's not (it has nothing to do with the code from the delete function)
try
{
    string s = "select max(Id) as Id from dbo.Artikelen";
    SqlCommand cmd = new SqlCommand(s, con);
    con.Open();
    SqlDataReader dr = cmd.ExecuteReader();
    dr.Read();
    int i = Convert.ToInt32(dr["Id"].ToString());
    labelArtikelID.Text = (i + 1).ToString();
    con.Close();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
 
     
     
    