Views (collection), CommandText (exemple de propriété) (VB)
Le code suivant montre comment utiliser la propriété Command pour mettre à jour le texte d’une vue.
' BeginViewsCollectionVB
Sub Main()
On Error GoTo ViewTextError
Dim cnn As New ADODB.Connection
Dim cat As New ADOX.Catalog
Dim cmd As New ADODB.Command
' Open the connection.
cnn.Open _
"Provider='Microsoft.Jet.OLEDB.4.0';" & _
"Data Source='Northwind.mdb';"
' Open the catalog.
Set cat.ActiveConnection = cnn
' Get the command.
Set cmd = cat.Views("AllCustomers").Command
' Update the CommandText of the command.
cmd.CommandText = _
"Select CustomerId, CompanyName, ContactName From Customers"
' Update the view.
Set cat.Views("AllCustomers").Command = cmd
'Clean up.
cnn.Close
Set cat = Nothing
Set cmd = Nothing
Set cnn = Nothing
Exit Sub
ViewTextError:
Set cat = Nothing
Set cmd = 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
' EndViewsCollectionVB
Voir aussi
ActiveConnection, propriété (ADOX)
Catalog, objet (ADOX)
Command, propriété (ADOX)
View, objet (ADOX)
Views, collection (ADOX)
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour