Set Parameter to Null Workaround
Posted: Tue 23 Feb 2010 21:47
The instructions in the Delphi 2006 help say:
When I do that using my DevArt DBXpress driver for Interbase, I get an error message that says "No value for parameter 'hRec'." I have been able to get my query to work using this workaround code:
I included this workaround for anyone else it might help but it would be helpful if the code like the Delphi help states.
I really appreciate having your driver just the same. Thanks for all your work.
Jack
Following those instructions, if you want to set an integer variable to Null, you should be able to do something like this:Whenever a value is assigned to the TParam object, Bound is automatically set to true. Set Bound to false to undo the setting of a value. The Clear method replaces the value of the parameter with NULL, but does not set Bound to false. However, if the Clear method is used to bind the parameter to a NULL value, Bound must be separately set to true.
Code: Select all
FQuery.ParamByName('hRec').Clear;
FQuery.ParamByName('hRec').Bound := True;
Code: Select all
FQuery.ParamByName('hRec').AsInteger := 0;
FQuery.ParamByName('hRec').Clear;
I really appreciate having your driver just the same. Thanks for all your work.
Jack