IBE.SQL.EliteDBIO.getFreeIndex C# (CSharp) Method

getFreeIndex() private method

get the next free index for the table (positive only)
private getFreeIndex ( String TableName ) : UInt32
TableName String
return System.UInt32
        private UInt32 getFreeIndex(String TableName)
        {
            String sqlString ;
            UInt32 retValue = 0;
            DataTable data  = new DataTable();

            try
            {
                // get the highest ID from the table
                sqlString = "select max(id) As max_id from " + TableName;
                Program.DBCon.Execute(sqlString, data);

                if (Convert.IsDBNull(data.Rows[0]["max_id"]))
                    retValue = 0;
                else
                {
                    retValue = ((UInt32)data.Rows[0]["max_id"]) + 1;
                }

                return retValue;
            }
            catch (Exception ex)
            {
                throw new Exception("Error while determine the next free id", ex);
            }
        }