Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 22.03.08 21:51 
Hi, Delpher,

ich bekomme die folgende Fehlermeldung:

Unbekanntes Schlüsselwort 'asc' (im SQL-String)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.DBGrid4TitleClick(Column: TColumn);
var SortCol: String;
begin
  SortCol := DBGrid4.Columns.Items[Column.Index].FieldName;
  showmessage(SortCol);  // Feldname wird angezeigt!
  SortOrder := true;
  QBuchstamm.Close;
  if SortOrder then
    QBuchstamm.sql.text := format('select * from "%s" order by "%s" asc', [TbBuchstamm.tablename, SortCol])
  else
    QBuchstamm.sql.text := format('select * from "%s" order by "%s" desc', [TbBuchstamm.tablename, SortCol]);
  QBuchstamm.Open;
  SortOrder := not SortOrder;
end;


obwohl der Feldname schön angezeigt wird.

Wer hat eine Idee?
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Sa 22.03.08 22:24 
Glaub, bei asc Sortierung kann man das Wort weglassen, also einfach nur "order by %s"
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 23.03.08 10:17 
Hi, Xentar,

nun, die Lösung hast du "zufällig" mitgeliefert:

Man muss die zweiten doppelten Anführungszeichen weglassen 8)

also:

format('select * from "%s" order by %s asc', [TbBuchstamm.tablename, SortCol]);

(Das asc ist in der Tat fakultativ.)

Vielen Dank für diesen Treffer,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: So 23.03.08 17:31 
Das war aber nicht geplant.. :D

Aber wenn wir grad dabei sind: Um den Tablename die beiden "" kann man dann wahrscheinlich auch weg lassen.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 24.03.08 11:04 
Hi, Xentar!

NEIN, die nicht!! :? :shock: :lol:

Bis auf weiteres,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas