🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #5169

Re: Setting a TParameter to NULL

#5169
From: Giuliano
Date: Wed, 01 Aug 2001 21:03
55 lines
2528 bytes
On Wed, 1 Aug 2001 10:29:59 -0700, "John Biddle" <johnb@vigilant-systems.com>
wrote:

>I have a TADOQuery hooked up to a MS SQL Server 7.0 database.
>I am trying to execute a parameterized insert statement to update a
>VARCHAR(64) field that is nullable in the SQL database.
>
>ADO will not allow me to set this parameter to NULL.
>It always raises an exception:
>'Parameter object is improperly defined.
>Inconsistent or incomplete information was provided'
>
>I have tried all of the following without success:
>
>Assigning the TParameter to an empty variant (VT_EMPTY).
>Assigning the TParameter to an null variant (VT_NULL).
>Setting the TParameter Attributes to pa_Nullable.
>Setting the TADOQuery ParamCheck to false.
>
>The query works fine if I replace the parameter in the SQL text with the
>NULL keyword.
>
>I have lots of parameters in this query and would really like to avoid
>having
>to generate the SQL at runtime.
>
>Any ideas?!?!?!?!?
>

Hi John,

    I've tried to create a table like the following on MSSQL SERVER 7:

CREATE TABLE [dbo].[NULLTEST] (
  [ID] [int] IDENTITY (1, 1) NOT NULL,
  [NULLTEST] [varchar] (64) NULL 
);

Next, I've created a project that has a TADOCommand which has the CommandText

property that's filled with the following string:  

insert into NULLTEST ( NULLTEST ) values ( :NULLTEST )

Running the following lines of code, it insert a NULL in the column NULLTEST.

    ADOCommand1->Parameters->ParamByName( "NULLTEST" )->Value = Variant();
    ADOCommand1->Execute();

Sorry, but I haven't any idea to solve your problem because I can't be able to
reproduce it.

Ciao!

Giuliano
Technical Details
Message-ID: <3b686b51.68849410@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews
References: <3b683e99$1_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,fd4a14ecd8537884
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2001-08-01 14:13:04 PST
From: gcardinali@remove.adhoc.net (Giuliano)
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Re: Setting a TParameter to NULL
Date: Wed, 01 Aug 2001 21:03:12 GMT
Message-ID: <3b686b51.68849410@newsgroups.borland.com>
References: <3b683e99$1_1@dnews>
X-Newsreader: Forte Agent 1.5/32.451
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 194.183.68.92
X-Trace: dnews 996700113 194.183.68.92 (1 Aug 2001 14:08:33 -0700)
Lines: 55
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews