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

NumericScale and Precision Properties Example

This example uses the NumericScale and Precision properties to display the numeric scale and precision of fields in the Discounts table of the Pubs database.

Public Sub NumericScaleX()

	Dim rstDiscounts As ADODB.Recordset
	Dim fldTemp As ADODB.Field
	Dim strCnn As String

	' Open recordset.
	strCnn = "driver={SQL Server};server=srv;" & _
		"uid=sa;pwd=;database=pubs"
	Set rstDiscounts = New ADODB.Recordset
	rstDiscounts.Open "discounts", strCnn, , , 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

	rstDiscounts.Close

End Sub

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