Bonjour

Je suis rendu a l'étape 2 de mon évolution en MsSql

J'utilisais la commande filter
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
     TBILLET.FILTER:= 'D_DATE >'+ ''''+ DATEDEPART + ''''+ ' AND ' + 'D_DATE <'+ ''''+ datetostr(DATETIMEPICKER2.DATE+1) + ''''+ ' and ' +
                     'D_MATERIEL ='+ ''''+ combobox1.text + ''''  + ' and ' + 'D_CODE1 ='+ ''''+ 'ville' + '''' + ' AND '+ 'D_NOCONT ='+ ''''+ combobox1.text + '''' ;
Je veux remplace la commande filter par une commande MsSql qui marche tres bien
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
MSQuery1.Active:=False;
MsQuery1.SQl.Clear;
MsQuery1.SQL.Add('Select * from BILLET.dbo.BILLET');
MsQuery1.SQL.Add('where D_DATE BETWEEN :FROMDATE AND :TODATE');
MsQuery1.SQL.Add('and d_code = :ville'); // remplaçable par MsQuery1.SQL.Add('and d_code ='+QuotedStr('VILLE')); 
MsQuery1.SQL.Add('and  D_nocont = :contrat');
msQuery1.ParamByName('FROMDATE').asDateTime:=DateTimePicker1.Date-1;
msQuery1.ParamByName('TODATE').asDateTime:=DateTimePicker1.Date+7;
msQuery1.ParamByName('ville').asstring:='VILLE'; // inutile en cas de l'utilisation du remplacement proposé
msQuery1.ParamByName('contrat').asstring:=combobox1.text;
MsQuery1.Active:=True;
Un grand merci a M.SergioMaster pour cette solution

Je suis rendu a utiliser :
comment utiliser le resultat de ce Query
je peux associé le Query a un datasource ca va bien pour un DBdrid
mais si je veux copier le resultat dans une autre table pour travailler sur le champs
ou travailler directememt sur le resultat du Query

Merci de m'aider

Mario