Microsoft ActiveX Data ObjectsMicrosoft ActiveX Data Objects*
*Contents  *Index  *Topic Contents

ActualSize and DefinedSize Properties Example

This 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;" & _
		"uid=sa;pwd=;database=pubs"
	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.
	rstStores.MoveFirst

	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
		rstStores.MoveNext
	Loop

	rstStores.Close

End Sub

Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.