The following code is a static function used to calculate the NEXT ID created by the database. The code needs to perform a basic initial check to ensure that if there are no records in the table it can take the appropriate action. eg Make the First row 1. eg Try/Catch or IF/Else.
public static int SiteIDMax()
SiteID = Convert.ToInt32(ew_ExecuteScalar("SELECT max(SiteID) FROM DMPDB.DMP_Sites"))+ 1;