Help Center

CADOField.ActualSizeproperty

Indicates the actual length of a field's value.

DatabasespropertyCADOField.incdocumented

Syntax

PROPERTY ActualSize () AS ADO_LONGPTR

Return value

The actual length of the field's value.

Description

Indicates the actual length of a field's value. Some providers may allow this property to be set to reserve space for BLOB data, in which case the default value is 0.

Remarks

Use the ActualSize property to return the actual length of a field value. For all fields, the ActualSize property is read-only. If ADO cannot determine the length of the field value, the ActualSize property returns adUnknown.

The ActualSize and DefinedSize properties are different. A field with a declared type of adVarChar and a maximum length of 50 characters returns a DefinedSize property value of 50, but the ActualSize property value it returns is the length of the data stored in the field for the current record. Fields with a DefinedSize greater than 255 bytes are treated as variable length columns.

Example

#include once "AfxNova/CADODB.inc" USING AfxNova

' // Open the connection DIM pConnection AS CAdoConnection pConnection.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=biblio.mdb")

' // Set the cursor location DIM pRecordset AS CAdoRecordset pRecordset.CursorLocation = adUseClient

' // Open the recordset DIM dvSource AS DVARIANT = "SELECT * FROM Publishers" pRecordset.Open(dvSource, pConnection, adOpenKeyset, adLockOptimistic, adCmdText)

' // Get a reference to the Fields collection DIM pFields AS CAdoFields = pRecordset.Fields

' // === Parse the recordset ' // While not at the end of the recordset... DO WHILE NOT pRecordset.EOF ' // Get the contents of the fields DIM pField AS CAdoField pField.Attach(pFields.Item("Name")) DIM dvRes AS DVARIANT = pField.Value PRINT "Name: "; dvRes; " - "; WSTR(pField.ActualSize); " - "; WSTR(pField.DefinedSize) ' // Fetch the next row IF pRecordset.MoveNext <> S_OK THEN EXIT DO LOOP

' // === Close the recordset and the connection ' // If you don't close them, they will be closed when the application ends pRecordset.Close pConnection.Close

Reference

  • Include file CADOField.inc
  • Defined in AfxNova/CAdoFields.inc:216
  • Documented in Databases/ADO Classes/CAdoFields Class.md
  • Topic: CAdoFields Class