Inserting NULL

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 3
Joined: Sat 19 Nov 2016 20:19

Inserting NULL

Post by bdkacz » Mon 21 Nov 2016 13:22


How to insert NULL as parameter for TMSSQL ?

For example I have code like that :

Code: Select all

if (some if statement)  then
aqZapisz.ParamByName('p1').AsInteger := 1
aqZapisz.ParamByName('p1').Value := Variants.null

but I receive error that I need to use convert to insert nulll..
The column is defnded as int type with allow nulls

Posts: 13
Joined: Wed 03 Feb 2010 10:32
Location: Germany, Siegen (NRW)

Re: Inserting NULL

Post by asc » Tue 22 Nov 2016 10:14

In C++ works something like:

Code: Select all

void SetNullParam(
    TMSQuery * query,
    String const & parameterName,
    TFieldType parameterTyp)
    query->ParamByName(parameterName)->Bound = true;
    query->ParamByName(parameterName)->DataType = parameterTyp;

Posts: 3
Joined: Sat 19 Nov 2016 20:19

Re: Inserting NULL

Post by bdkacz » Tue 22 Nov 2016 10:29

In Delphi also works great,thank you

Devart Team
Posts: 1001
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Inserting NULL

Post by azyk » Wed 23 Nov 2016 09:26

Calling the Clear method and value setting to the DataType property to ftInteger for dataset parameter is a correct way to set a NULL value to the int parameter.

Post Reply