View Full Version : Solved: ADO Recordset - Field Attributes

05-08-2006, 11:22 AM
I have a situation where off-site users who do not have Office, but have MDAC installed will create and persist an ADO Recordset with a variable number of fields. I am experimenting with using the Recordset's field status property for validation. With a combination of field type, field attributes and status I hope to ensure valid entry without resort to writing custom code for each field. I would appreciate assistance with the following problem, which almost looks like a bug in MDAC.

A field 'age' needs to be defined as allowing no negative numbers, can be null, and between 0-99. Therefore the field is appended to the Recordset as

'adUnsignedTinyInt= 17 'Indicates a one-byte unsigned integer.
oRS.Fields("age").DefinedSize =2
oRS.Fields("age").Precision =2

I realize that DefinedSize probably refers to chars, but when persisted the xml looks like

<s:AttributeType name='age' rs:number='2' rs:nullable='true' rs:write='true'>
<s:datatype dt:type='ui1' dt:maxLength='2' rs:precision='2' rs:fixedlength='true'/>

but age will still accept a 3-digit value, like 101:banghead: (the status property will return an error for 1001, but that merely reflects the 1 byte boundary of the field type).

Also, I cannot make a field 'required' from just the Recordset Object. I do not believe I can use ADOX as that requires a Connection Object whereas a Recordset can be 'fabricated'.

Hope this makes sense. Stan

05-09-2006, 02:49 AM
My Bad. I totally skipped over datatype 131 (Fixed Precision and Scale).:doh: Stan