Autor Beitrag
Robby
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 31

Winxp
Delphi 4
BeitragVerfasst: Fr 25.11.05 17:58 
Hallo zusammen, kann man diese Code auch kürz, und schneller machen in SQL.
Für eure Hilfe wehre ich Dankbar :D
:?:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
stName:='';
 text_t:='Bitte Stücklistennummer  eingeben';
if InputQuery(text_t,'',stName)then
query1.sql.clear;
query1.sql.add('select');
query1.sql.add('*from lager.dbf');
query1.sql.add('AS lager');
query1.sql.add('Where');
query1.sql.add('Znr='+Quotedstr(stName));
query1.sql.add(' order by Znr'); }
query.active:= true;
query.first;


Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.

_________________
Es gibt keine dummen Fragen,
nur dumme Antworten.
Jochen W.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 56



BeitragVerfasst: Fr 25.11.05 18:06 
vielleicht so:
ausblenden Delphi-Quelltext
1:
query1.sql.add('select * from lager.dbf AS lager Where Znr='+Quotedstr(stName) + ' order by Znr');					
Robby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 31

Winxp
Delphi 4
BeitragVerfasst: Fr 25.11.05 18:26 
Ich bekomme die Fehlermeldung Ungültiges Schlüsselwort ‚select’ Hilfe
Jochen W.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 56



BeitragVerfasst: Fr 25.11.05 18:29 
Hast du die Fehlermeldung vorher nicht erhalten?
stifflersmom
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194

XP /XP PRO/ SuSE div.
D1 - D7, BDS 2006
BeitragVerfasst: Fr 25.11.05 18:33 
Steht in Deiner sql-Anweisung schon was drin?

Mach doch mal sicherheitshalber ein
ausblenden Delphi-Quelltext
1:
ShowMessage(query1.sql.text)					


und sieh Dir genau an, was da überhaupt abgeschickt wird.

Moin
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Fr 25.11.05 18:54 
nimm parameter!
e.g.

in deiner Query:
ausblenden SQL-Anweisung
1:
' select * from lager.dbf where znr= :Stueckliste order  by znr';					


dieses kannst du zur Entwurfzeit schon machen.

Im Quelltext:

ausblenden Delphi-Quelltext
1:
2:
Query.Parameters.ParamByName('Stueckliste').Value:=[Wert] oder [Zeichenkette] ;
Query.Open;


grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Fr 25.11.05 19:09 
Ich verwende beim SQL nie Add, ausser ich will wirklich was anhängen. Sicherer, wie, wen auch indirekt, hier schon erwähnt, ist das Zuweisen per Text-Eigenschaft.
Wirklich sicher sind nur diese Möglichkeiten:
ausblenden Delphi-Quelltext
1:
2:
MyQuery.Sql.Clear;
MyQuery.Sql.Add('select * from Foo');

oder eben
ausblenden Delphi-Quelltext
1:
MyQuery.Sql.Text := 'select * from Foo';					

_________________
Na denn, dann. Bis dann, denn.
Robby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 31

Winxp
Delphi 4
BeitragVerfasst: Fr 25.11.05 19:12 
ich habe den Code so umgebastelt
Ist alles Ok
Danke an alle
ausblenden Delphi-Quelltext
1:
2:
query.sql.text:='select * from Lager.dbf AS Lager Where Znr='
+Quotedstr(stName) + ' order by Znr';


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.