' Gambas class file STATIC PRIVATE $cInfo AS NEW Collection STATIC PRIVATE $cKey AS NEW Collection STATIC PRIVATE $cFields AS NEW Collection STATIC PRIVATE $cTable AS NEW Collection STATIC PUBLIC SUB _init() TRY DB.Open END STATIC PUBLIC FUNCTION _get(sTable AS String, sField AS String, OPTIONAL bCreate AS Boolean) AS DataField DIM hTable AS Table DIM hField AS Field DIM iType AS Integer DIM bReadOnly AS Boolean DIM hInfo AS DataField DIM sKey AS String sKey = sTable & "." & sField IF bCreate THEN sKey &= "." IF NOT $cInfo.Exist(sKey) THEN hTable = DB.Tables[sTable] hField = hTable.Fields[sField] iType = hField.Type hInfo = NEW DataField hInfo.Name = hField.Name hInfo.Key = hTable.PrimaryKey.Find(sField) >= 0 hInfo.Default = hField.Default IF iType = db.Serial THEN iType = db.Long bReadOnly = TRUE ELSE bReadOnly = hInfo.Key IF bCreate THEN bReadOnly = FALSE ENDIF hInfo.Type = iType hInfo.ReadOnly = bReadOnly IF iType = db.String THEN hInfo.Length = hField.Length ENDIF $cInfo[sKey] = hInfo ENDIF RETURN $cInfo[sKey] END STATIC PUBLIC FUNCTION GetDefaultValue(sTable AS String, sField AS String) AS Variant RETURN DataConnection[sTable, sField].Default END STATIC PUBLIC FUNCTION GetPrimaryKey(sTable AS String) AS String[] IF NOT $cKey.Exist(sTable) THEN $cKey[sTable] = DB.Tables[sTable].PrimaryKey ENDIF RETURN $cKey[sTable] END STATIC PUBLIC FUNCTION GetFields(sTable AS String) AS String[] DIM aField AS String[] DIM hField AS Field IF NOT $cFields.Exist(sTable) THEN aField = NEW String[] FOR EACH hField IN DB.Tables[sTable].Fields aField.Add(hField.Name) NEXT $cFields[sTable] = aField ENDIF RETURN $cFields[sTable] END STATIC PUBLIC FUNCTION ExistTable(sTable AS String) AS Boolean IF NOT $cTable.Exist(sTable) THEN $cTable[sTable] = DB.Tables.Exist(sTable) ENDIF RETURN $cTable[sTable] END .