VB6: Command + paramètre - VB/VBA/VBS - Programmation
Marsh Posté le 13-05-2003 à 11:25:37
J'ai trouvé: 
il faut simplement faire 
dataEnvironement.maComande(monParametre) 
 
 
Mon pb est maintenant le suivant: le parametre attendu est un String et lorsque je fais maCommande("0001" ) : "Paramatre de type incorrecet ou en conflit avec les autres...." 
 
 
une idée ???
Marsh Posté le 13-05-2003 à 11:27:48
Essaie déjà avec un champ numérique, histoire d'être sûr.
Marsh Posté le 13-05-2003 à 11:33:23
Sinon, la syntaxe, c'est : 
 
|   | 
 
 
Voilà u exemple complet, utilisant une autre syntaxe : 
 
|   | 
Marsh Posté le 13-05-2003 à 11:35:38
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
Marsh Posté le 13-05-2003 à 11:16:07
Bonjour
J'ai créé une commande contenant une requete sql du genre "Select * from Matable where code= ?"
et j'ai appellé mon parametre parCode.
Lorsque j'appelle ma commande, comment je fais pour spécifier la valeur du parametre.
(appelle de la commande: dataEnvironnement.maCommande)
D'avance merci