Board index » delphi » Query problem - with date

Query problem - with date

i have made the this:

If StrToDate(FraDato) <= StrToDate(TilDato) Then
  Begin
   QPeriode2.SQL.Clear;
   QPeriode2.SQL.Add('SELECT * FROM RAPPORT WHERE (Dato > :FINDSTART) AND
(Dato < :FINDslut)');
   QPeriode2.ParamByName('FINDSTART').AsDate := StrToDate(FraDato);
   QPeriode2.ParamByName('FINDslut').AsDate  := StrToDate(TilDato);
   QPeriode2.Active := True;
  end
  else
   Begin
    If MessageDlg('Data omr?det er tomt', mtConfirmation,
                 [mbYes, mbNo], 0) = mrYes THEN
                 RapportForm.Close;
   End;
end;

It works ok - but if

FraDato = 02-04-99
TilDato  = 02-05-99

I get an error - something like QPeriode2 is not in edit or insert mode,
howcome ?

Thanx in advance

--
mvh......
Ulrik Vadstrup
vadst...@post12.tele.dkX
http://home12.inet.tele.dk/vadstrup/ulrikhome.htm

 

Re:Query problem - with date


On Wed, 5 May 1999 20:29:27 +0200, "Ulrik Vadstrup"

Quote
<vadst...@post12.tele.dk> wrote:
>i have made the this:

>If StrToDate(FraDato) <= StrToDate(TilDato) Then
>  Begin
>   QPeriode2.SQL.Clear;
>   QPeriode2.SQL.Add('SELECT * FROM RAPPORT WHERE (Dato > :FINDSTART) AND
>(Dato < :FINDslut)');

Don't you need (Dato >= :FINDSTART) and (Dato <= FINDslut)?

Quote
>   QPeriode2.ParamByName('FINDSTART').AsDate := StrToDate(FraDato);
>   QPeriode2.ParamByName('FINDslut').AsDate  := StrToDate(TilDato);
>   QPeriode2.Active := True;
>  end
>  else
>   Begin
>    If MessageDlg('Data omr?det er tomt', mtConfirmation,
>                 [mbYes, mbNo], 0) = mrYes THEN
>                 RapportForm.Close;
>   End;
>end;

>It works ok - but if

>FraDato = 02-04-99
>TilDato  = 02-05-99

>I get an error - something like QPeriode2 is not in edit or insert mode,
>howcome ?

Your result set is empty, maybe this is causing a problem.
Quote

>Thanx in advance

>--
>mvh......
>Ulrik Vadstrup
>vadst...@post12.tele.dkX
>http://home12.inet.tele.dk/vadstrup/ulrikhome.htm

HTH,
Dan
--
Dan Brennand
CMDC systems, inc.
Configuration Management and Document Control: Consulting, Software,
and the only comprehesive textbook on this subject.
visit us at www.cmdcsystems.com
[Remove the SPAM from my e-mail address]

Other Threads