you try this code which retrieve the last row form your table
private int NewId(){
SqlConnection con = new SqlConnection(
SqlDataAdapter adapter = new SqlDataAdapter("Select * from yourtablename", con);
SqlCommandBuilder cmd = new SqlCommandBuilder(adapter);
DataSet ds = new DataSet();
adapter.Fill(ds);
int ID = 0;
if (ds.Tables[0].Rows.Count > 0)
{
int len = ds.Tables[0].Rows.Count - 1;
ID = int.Parse(ds.Tables["Arcticle"].Rows[len]["arcId"].ToString()) + 1;
}
else
ID = 1;
return ID;
}
you call above function where you need to new id.