ONE Active Server Pages Product Home Page Developer Site Version


ADO Field Object ActualSize Property

The actual length of a field's value.

ActualSize Property Return Values (ADO Field Object)

Returns a Long value. Some providers may allow this property to be set to reserve space for BLOB data, in which case the default value is 0.

ActualSize Property Remarks (ADO Field Object)

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

The ActualSize and ADO Field Object DefinedSize Property properties are different as shown in the following example: a Field object 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.

ActualSize Property Example (ADO Field Object)

This Visual Basic example uses the ActualSize and DefinedSize properties to display the defined size and actual size of a field.

Public Sub ActualSizeX()
Dim rstStores As ADODB.Recordset 
Dim strCnn As String
' Open a recordset for the Stores table. 
strCnn = "driver={SQL Server};server=srv;" & _ 
Set rstStores = New ADODB.Recordset 
rstStores.Open "stores", strCnn, , , adCmdTable
' Loop through the recordset displaying the contents 
' of the stor_name field, the field's defined size, 
' and its actual size. 
Do Until rstStores.EOF 
MsgBox "Store name: " & rstStores!stor_name & _ 
vbCr & "Defined size: " & _ 
rstStores!stor_name.DefinedSize & _ 
vbCr & "Actual size: " & _ 
rstStores!stor_name.ActualSize & vbCr 
End Sub