Subject Re: [IBO] Dates in TIBOQuery vs. PrepareSQL
Author Tony Masefield
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
>> First, PLEASE TRIM YOUR MESSAGES !!!
>
OK, sorry, my mistake!
>
> As Alan pointed out, doubling is the correct way to escape
apostrophes in
> Pascal (and in Firebird, as well, as it happens!)
>
> However, relying on date literals in SQL from the client side is
not the
> recommended way to do this, if it can possibly be avoided. Use
parameters
> and then, in your "before" event, use AsDate or AsDateTime to
assign the date.
>
> viz.
>
> MyDataset.SQLWhereItems.Add('where ADate >= :ADate');
>
> Then (assuming you're using the search in a dataset):
>
> MyDataset.ParamByName('ADate').AsDateTime := YourDateTimeVariable;
>
> Helen
>
Thanks (again) Helen. The change from desktop to server is more
complex (i.e. learning curve) than I had envisaged at first.
Progression is gradual but assured with your help.
Will use your approach from now one. Complicating factor was the
info in the IBO GSTG IRO the information on 'OnPrepareSQL' which was
what I was following. Somewhere I lost out on Paramatized Queries
(paramter bindings). Thanks for 'jogging' my memory.

Rgds,
Tony