Exemple de code ADOX : NumericScale et Precision, exemple de propriétés (VB)
Cet exemple illustre les propriétés NumericScale et Precision de l’objet Column. Ce code affiche leur valeur pour la table Order Details de la base de données Northwind.
' BeginNumericScalePrecVB
Sub Main()
On Error GoTo NumericScalePrecXError
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='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
'Clean up
cnn.Close
Set cat = Nothing
Set cnn = Nothing
Exit Sub
NumericScalePrecXError:
Set cat = Nothing
If Not cnn Is Nothing Then
If cnn.State = adStateOpen Then cnn.Close
End If
Set cnn = Nothing
If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub
' EndNumericScalePrecVB
Voir aussi
Column, objet (ADOX)
NumericScale, propriété (ADOX)
Precision, propriété (ADOX)
Commentaires
https://aka.ms/ContentUserFeedback.
Prochainement : Tout au long de l'année 2024, nous supprimerons progressivement les GitHub Issues en tant que mécanisme de retour d'information pour le contenu et nous les remplacerons par un nouveau système de retour d'information. Pour plus d’informations, voir:Soumettre et afficher des commentaires pour