Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query .ParamByName - MSSQL 1

Status
Not open for further replies.

castore

Programmer
Apr 1, 2005
18
0
0
IT
D7 - MSSQL

I have a table with a numeric integer field that can accept Null
(Table -> T1 Field -> F1)

My elementary query is:
update T1 set F1 = :param

and then in my code:

query.ParamByName('param').AsInteger := 10;
query.Excecute;

It works fine.

But, how can i do if i want to set F1 to Null?
How must write ?
query.ParamByName('param').????? = Null ????

thanks to all
castore
 
How about:

query.ParamByName('param').Value := null;

Hmmm,

As I look at that I wonder if your query would work correctly. If you substitute your parameter value you 'might' get:

update T1 set F1 = NULL

If that doesn't work you could always re-set the SQL without using the parameter to:

Code:
query.sql.clear;
query.sql.add(
  'UPDATE T1'+
  ' SET'+
  ' F1=NULL'
);
query.execsql;

query.sql.clear;
query.sql.add(
  'UPDATE T1'+
  ' SET'+
  ' F1=:param'
);


Regards,

Django
 
Thank Django
query.ParamByName('param').Value := null;
works !!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top