Le post complet d'où est tiré mon exemple :
I had to post this again because the HTML got munged the first time...
OK. There is a Parameters collection associated with the Command
object. You can also set the command text and command type.
Set Cmd1 = New ADODB.Command
Set Cmd1.ActiveConnection = Conn1
Cmd1.CommandText = "SELECT * FROM Authors WHERE AU_ID = ?"
Set Param1 = Cmd1.CreateParameter(, adInteger, adParamInput, 10)
Param1.Value = 10
Cmd1.Parameters.Append Param1
Set Param1 = Nothing
Set Rs1 = Cmd1.Execute()
The '?' in the string represents a parameter. Multiple '?' can be used for multiple parameters. The parameters are applied in the order they are appended, I believe.
This article:
http://msdn.microsoft.com/library/ [...] 97/ado.htm
Describes using the parameters collection pretty completely. Another alternative is to build a string and then execute the string. The problem with this of course is making sure that the data type is represented correctly (for instance, a string with an embedded single quote, how you format dates might be provider dependent).
-- Edit : Pour les constantes à passer à createparameter, cherche sur le net leur définition
Message édité par MagicBuzz le 13-05-2003 à 11:38:32