Consulting

Results 1 to 2 of 2

Thread: Solved: ADO Recordset - Field Attributes

  1. #1
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location

    Solved: ADO Recordset - Field Attributes

    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.Append("age",17,,16|32|64)
    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 (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

  2. #2
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    My Bad. I totally skipped over datatype 131 (Fixed Precision and Scale). Stan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •