遵循Vba例程:
Dim CampoRS As string
Dim Requerido As Boolean
Dim Zero As Bollean
Dim rs As DAO.Recordset
With frmCurriculum
Set rs = dbCRM.OpenRecordset("SELECT * FROM tblCurriculum", dbOpenDynaset, dbSeeChanges, dbPessimistic)
rs.MoveFirst
For n = 0 To .Controls.Count - 1
CampoRS = .Controls.item(n).Tag
Requerido = rs.Fields(CampoRS).Required
Zero = rs.Fields(CampoRS).AllowZeroLenght
...
使用DAO,这个例程获取属性";"必需";以及";AllowZeroLenght";记录集中字段的。
我需要获得相同的属性,但使用ADO
如果你看这里https://flylib.com/books/en/3.9.1.29/1/您可以看到Field.Attributes
属性是一个位掩码,因此您可以检查例如
(rs.Fields("Name").Attributes and 64) = 64
(或使用adFldMayBeNull
ADO常量)来检查字段是否可以为null,但我看不到"的等价项;允许零长度";那里
如果您想要DAO/ADOX这两个属性,那么在这种情况下可能需要DAO/ADOX。