Autor Beitrag
Krischa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

Windows 7 64 Bit
Delphi 2007
BeitragVerfasst: Di 23.06.09 09:29 
Hi,
ich ersetzte gerade in meine ganzen SQL-Abfragen die Variablen durch Parameter. Es kalppt schon ganz gut nur an einer stelle hänge ich jetzt.
Alte Abfrage:
ausblenden Delphi-Quelltext
1:
query2.SQL.Text:='SELECT LS_RG FROM '+kun_s1+' WHERE ART="'+prod[j].ian+'" AND EDATUM>"'+rechdatum+'" AND LS_RG IS NOT NULL';					

Die Abfrage hat einwandfrei funktioniert.

Neue Abfrage:
ausblenden Delphi-Quelltext
1:
2:
3:
query2.SQL.Text:='SELECT LS_RG FROM '+kun_s1+' WHERE (ART=:ParamART) AND (EDATUM>:ParamEDATUM) AND LS_RG IS NOT NULL';
query2.Params.ParamByName('ParamART').Value:=prod[j].ian;
query2.Params.ParamByName('ParamEDATUM').Value:=rechdatum;

Beim ersten Parameter gibt es noch keine Probleme aber wie mache ich das beim Zweiten(ParamEDATUM). Hier gibt es im Programm eine Exception.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 23.06.09 10:07 
Die da wäre welche? Kristallkugeln haben in diesem Forum Seltenheitswert ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
tif
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46
Erhaltene Danke: 1

Winxxx
TP, BP, Delphi 1 - 2009
BeitragVerfasst: Di 23.06.09 10:12 
Hallo,

du mußt noch den Parameter - Datentyp definieren, sonst übergibt die query die Parameter nicht korrekt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
query2.SQL.Text:='SELECT LS_RG FROM '+kun_s1+' WHERE (ART=:ParamART) AND (EDATUM>:ParamEDATUM) AND LS_RG IS NOT NULL';
query2.Params.ParamByName('ParamART').datatype:=ftString;
query2.Params.ParamByName('ParamART').Value:=prod[j].ian;
query2.Params.ParamByName('ParamEDATUM').datatype:=ftDateTime;
query2.Params.ParamByName('ParamEDATUM').Value:=rechdatum;
Krischa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

Windows 7 64 Bit
Delphi 2007
BeitragVerfasst: Di 23.06.09 10:16 
Da du ja doch nicht Hellsehen kannst hier die Fehlermeldung:
Zugriffsverletztung bei Adresse 7C91E913 in Modul "ntdll.dll". Lesen von Adresse 01621498.

Wie gesagt mit der alten Variante geht es und mit der neuen nicht. Er hat ein Problem mit dem ParamEDATUM. Ich bin mir auch nicht sicher ob man bei Feld>Wert das so schreiben kann wie ich es getan habe.

@tif Die Variablen sind alles Strings. Muss ich dem dann wirklich noch sagen was es ist?
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 23.06.09 10:45 
Versuch es mal mit
ausblenden Delphi-Quelltext
1:
query2.Params.ParamByName('ParamEDATUM').Value:=StrToDate(rechdatum);					
Krischa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

Windows 7 64 Bit
Delphi 2007
BeitragVerfasst: Di 23.06.09 10:51 
Ok, mit StrtoDate hat es geklappt. Hätte nicht damit gerechnet das er da ein Datum haben will, weil er in der alten Version unbedingt Strings haben wollte.