Board index » delphi » TQuery.Parameters question

TQuery.Parameters question

In Delphi 5 the help for TQuery says that when using parameters, you can use
ones with NULL values;
However if I do this:    MyQuery.ParamByName('MyParam').AsString :=
MyString;
If MyString is NULL when I execute the query,
I get the error message:

General SQL error.
Conversion error from string ""

If it is not null it works ok.
If I do the exact same query using TIBQuery components, it works perfect
whatever the value of MyString.

Is this a bug, is there an easy work around?

 

Re:TQuery.Parameters question


Post this in the SqlServers newsgroup.

Re:TQuery.Parameters question


Quote
In article <393521ba@dnews>, Mark G wrote:
> In Delphi 5 the help for TQuery says that when using parameters, you can use
> ones with NULL values;
> However if I do this:    MyQuery.ParamByName('MyParam').AsString :=
> MyString;
> If MyString is NULL when I execute the query,

myString is never NULL. An empty string is not the same as a NULL value for a
data field. Use MyQuery.ParamByName('MyParam').Clear to set a parameter to
NULL.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads