You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ActualSize and DefinedSize Properties Example (VB) | Microsoft Docs
ms.prod
sql
ms.prod_service
connectivity
ms.technology
connectivity
ms.custom
ms.date
01/19/2017
ms.reviewer
ms.topic
conceptual
dev_langs
VB
helpviewer_keywords
DefinedSize property [ADO], Visual Basic example
ActualSize property [ADO], Visual Basic example
ms.assetid
bff2c273-b535-4b32-83b3-0336a406859c
author
MightyPen
ms.author
genemi
ActualSize and DefinedSize Properties Example (VB)
This example uses the ActualSize and DefinedSize properties to display the defined size and actual size of a field.
'BeginActualSizeVB 'To integrate this code 'replace the data source and initial catalog values 'in the connection string PublicSubMain()OnErrorGoToErrorHandler'recordset and connection variables DimrstStoresAsADODB.RecordsetDimSQLStoresAsStringDimstrCnxnAsString'record variables DimstrMessageAsString' Open a recordset for the Stores table strCnxn="Provider='sqloledb';Data Source='MySqlServer';"& _
"Initial Catalog='Northwind';Integrated Security='SSPI';"SetrstStores=NewADODB.RecordsetSQLStores="Suppliers"rstStores.OpenSQLStores,strCnxn,adOpenForwardOnly,adLockReadOnly,adCmdTable'the above two lines of code are identical as the default values for 'CursorType and LockType arguments match those indicated ' Loop through the recordset displaying the contents ' of the store_name field, the field's defined size, ' and its actual size. rstStores.MoveFirstDoUntilrstStores.EOFstrMessage="Company name: "&rstStores!CompanyName& _
vbCrLf&"Defined size: "& _
rstStores!CompanyName.DefinedSize& _
vbCrLf&"Actual size: "& _
rstStores!CompanyName.ActualSize&vbCrLfMsgBoxstrMessage,vbOKCancel,"ADO ActualSize Property (Visual Basic)"rstStores.MoveNextLoop' clean up rstStores.CloseSetrstStores=NothingExitSubErrorHandler:' clean up IfNotrstStoresIsNothingThenIfrstStores.State=adStateOpenThenrstStores.CloseEndIfSetrstStores=NothingIfErr<>0ThenMsgBoxErr.Source&"-->"&Err.Description,,"Error"EndIfEndSub'EndActualSizeVB