ActualSize 및 DefinedSize 속성 예제(VB)
다음 예제에서는 ActualSize 및 DefinedSize 속성을 사용하여 필드의 정의된 크기와 실제 크기를 표시합니다.
'BeginActualSizeVB
'To integrate this code
'replace the data source and initial catalog values
'in the connection string
Public Sub Main()
On Error GoTo ErrorHandler
'recordset and connection variables
Dim rstStores As ADODB.Recordset
Dim SQLStores As String
Dim strCnxn As String
'record variables
Dim strMessage As String
' Open a recordset for the Stores table
strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
"Initial Catalog='Northwind';Integrated Security='SSPI';"
Set rstStores = New ADODB.Recordset
SQLStores = "Suppliers"
rstStores.Open SQLStores, 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.MoveFirst
Do Until rstStores.EOF
strMessage = "Company name: " & rstStores!CompanyName & _
vbCrLf & "Defined size: " & _
rstStores!CompanyName.DefinedSize & _
vbCrLf & "Actual size: " & _
rstStores!CompanyName.ActualSize & vbCrLf
MsgBox strMessage, vbOKCancel, "ADO ActualSize Property (Visual Basic)"
rstStores.MoveNext
Loop
' clean up
rstStores.Close
Set rstStores = Nothing
Exit Sub
ErrorHandler:
' clean up
If Not rstStores Is Nothing Then
If rstStores.State = adStateOpen Then rstStores.Close
End If
Set rstStores = Nothing
If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub
'EndActualSizeVB
참고 항목
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기