NumericScale 및 Precision 속성 예제(VB)
이 예제에서는 NumericScale 및 Precision 속성을 사용하여 Pubs 데이터베이스의 Discounts 테이블에 필드의 숫자 배율 및 전체 자릿수를 표시합니다.
'BeginNumericScaleVB
'To integrate this code
'replace the data source and initial catalog values
'in the connection string
Public Sub NumericScaleX()
' connection and recordset variables
Dim rstDiscounts As ADODB.Recordset
Dim Cnxn As ADODB.Connection
Dim fldTemp As ADODB.Field
Dim strCnxn As String
Dim strSQLDiscounts As String
' Open connection
Set Cnxn = New ADODB.Connection
strCnxn = "Provider='sqloledb';Data Source='MySqlServer';Initial Catalog='Pubs';Integrated Security='SSPI';"
Cnxn.Open strCnxn
' Open recordset
Set rstDiscounts = New ADODB.Recordset
strSQLDiscounts = "Discounts"
rstDiscounts.Open strSQLDiscounts, Cnxn, adOpenStatic, adLockReadOnly, adCmdTable
' Display numeric scale and precision of
' numeric and small integer fields
For Each fldTemp In rstDiscounts.Fields
If fldTemp.Type = adNumeric Or fldTemp.Type = adSmallInt Then
MsgBox "Field: " & fldTemp.Name & vbCr & _
"Numeric scale: " & _
fldTemp.NumericScale & vbCr & _
"Precision: " & fldTemp.Precision
End If
Next fldTemp
' clean up
rstDiscounts.Close
Cnxn.Close
Set rstDiscounts = Nothing
Set Cnxn = Nothing
End Sub
'EndNumericScaleVB
참고 항목
Field 개체
NumericScale 속성(ADO)
Parameter 개체
Precision 속성(ADO)