Command et CommandText, exemples de propriétés (VB)
Le code suivant montre comment utiliser la propriété Command pour mettre à jour le texte d’une procédure.
' BeginProcedureTextVB
Sub Main()
On Error GoTo ProcedureTextError
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.Procedures("CustomerById").Command
' Update the CommandText.
cmd.CommandText = "Select CustomerId, CompanyName, ContactName " & _
"From Customers " & _
"Where CustomerId = [CustId]"
' Update the procedure.
Set cat.Procedures("CustomerById").Command = cmd
'Clean up.
cnn.Close
Set cat = Nothing
Set cmd = Nothing
Set cnn = Nothing
Exit Sub
ProcedureTextError:
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
' EndProcedureTextVB
Voir aussi
ActiveConnection, propriété (ADOX)
Catalog, objet (ADOX)
Command, propriété (ADOX)
Procedure, objet (ADOX)
Procedures, collection (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