Problème requête SQL [Lazarus]
Bonjour a tous,
Je viens vous demander si vous vous etes déjà trouvé devant ce cas, je m'explique :
J'ai une fonction qui me permet de pouvoir afficher des info de la DB mais si j'utilise exactement la meme en dessous j'ai un message :s
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| ////////////////////////////////// Recherche par année
SQLQuery1.Active:=False;
if ComboBox1.Text = 'Selectionnez' then
// ben rien :)
else
begin
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Text:='SELECT * FROM TableDossiers'+' WHERE annee = ' + ComboBox1.Items.Strings[ComboBox1.ItemIndex];
SQLQuery1.Active:=True;
SQLQuery1.First;
if (SQLQuery1.RecordCount > 0) then
begin
While not SQLQuery1.Eof do
begin
ListBox1.Items.Add(SQLQuery1.FieldByName('annee').AsString);
ListBox2.Items.Add(SQLQuery1.FieldByName('modele').AsString);
ListBox3.Items.Add(SQLQuery1.FieldByName('langue').AsString);
ListBox4.Items.Add(SQLQuery1.FieldByName('ref').AsString);
ListBox5.Items.Add(SQLQuery1.FieldByName('quantite').AsString);
ListBox6.Items.Add(SQLQuery1.FieldByName('NomDossiers').AsString);
SQLQuery1.Next;
end;
end;
SQLQuery1.Active:=False;
end;
///////////////////////////////////////
////////////////////////////////// Recherche par modèle
if ComboBox2.Text = 'Selectionnez' then
// ben rien :)
else
begin
test := ComboBox2.Items.Strings[ComboBox2.ItemIndex];
SQLQuery1.SQL.Clear;
SQLQuery1.Active:=False;
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Text:='SELECT * FROM TableDossiers WHERE modele = ' + test;
SQLQuery1.Active:=True;
SQLQuery1.First;
if (SQLQuery1.RecordCount > 0) then
begin
While not SQLQuery1.Eof do
begin
ListBox1.Items.Add(SQLQuery1.FieldByName('annee').AsString);
ListBox2.Items.Add(SQLQuery1.FieldByName('Modele').AsString);
ListBox3.Items.Add(SQLQuery1.FieldByName('langue').AsString);
ListBox4.Items.Add(SQLQuery1.FieldByName('ref').AsString);
ListBox5.Items.Add(SQLQuery1.FieldByName('quantite').AsString);
ListBox6.Items.Add(SQLQuery1.FieldByName('NomDossiers').AsString);
SQLQuery1.Next;
end;
end;
SQLQuery1.Active:=False;
end;
/////////////////////////////////////// |
voila, la première partir fonctionne parfaitement mais la seconde stipule "Trop peu de parametres :s" alors que c'est un simple SELECT, je ne sais quoi faire...
Merci beaucoup pour votre présence
inc002
EDIT : J'ai testé en séparant les deux block avec un 2nd bouton et le resulat est le même, est-ce un problème de syntaxe ?