MDAC 2.5 SDK - ADOX


 

NumericScale and Precision Properties Example (VB)

See Also

This example demonstrates the NumericScale and Precision properties of the Column object. This code displays their value for the Order Details table of the Northwind database.

Sub NumericScalePrecX()

    Dim cnn As New ADODB.Connection
    Dim cat As New ADOX.Catalog
    Dim tblOD As ADOX.Table
    Dim colLoop As ADOX.Column
        
    ' Connect the catalog.
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "data source=c:\Program Files\" & _
        "Microsoft Office\Office\Samples\Northwind.mdb;"
    Set cat.ActiveConnection = cnn
    
    ' Retrieve the Order Details table
    Set tblOD = cat.Tables("Order Details")
    
    ' Display numeric scale and precision of
    ' small integer fields.
    For Each colLoop In tblOD.Columns
        If colLoop.Type = adSmallInt Then
            MsgBox "Column: " & colLoop.Name & vbCr & _
                "Numeric scale: " & _
                    colLoop.NumericScale & vbCr & _
                "Precision: " & colLoop.Precision
        End If
    Next colLoop

End Sub