🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Problem still Occurring - Any ideas?

#985
From: Viatcheslav V. Vassiliev
Date: Tue, 22 Feb 2005 13:02
155 lines
6162 bytes
NULL in database is not the same as 0. What I mean - if you in C++ code 
write:

->ParamByName("...")->Value = NULL;

This NULL is C++ constant NULL, not NULL from database, and this C++ 
constant is equal integer 0, so if you want to pass set column to db NULL, 
you should pass OleVariant with type VT_NULL, ->ParamByName("...")->Value = 
NULL will set 0, not db NULL.



"Jochen Reichenberg" <jochen@jreichenberg.com> �������/�������� � �������� 
���������: news:421af267@newsgroups.borland.com...
>I might be wrong, but AFAIK NULL in a database does not mean 0. NULL means
> there is literally no value. 0 means the value is zero.
> You will get different results if you filter a table for NULL or 0!
>
> Joe
>
>
> "Viatcheslav V. Vassiliev" <support@oledbdirect.com> schrieb im 
> Newsbeitrag
> news:42093573@newsgroups.borland.com...
>> I mean type of OleVariant, not its value:
>>
>>  OleVariant Null;
>>  Null.VType  = VT_NULL;
>>
>> ->ParamByName("...")->Value = Null;
>>
>> Null should be defined in Variants unit (Variants.hpp) in C++ Builder 6 
>> or
>> somewhere else in C++ Builder 5. Note that Null is not the same as NULL.
>> Anyway, try code above.
>>
>> //------------------------------------------
>> Regards,
>> Vassiliev V. V.
>> http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
>> ADO.Net
>> http://www.oledbdirect.com - The fastest way to access MS SQL Server,
>> MS Jet (Access) and Interbase (through OLEDB)
>>
>> "Fridgerator" <lmoss@srcpmw.com> �������/�������� � �������� ���������:
>> news:4208fef3$1@newsgroups.borland.com...
>> >
>> > I have also tried to assign the OleVariant(VT_NULL) in the
> CreateParameter
>> > call.  This compiles fine but I get the same
>> > result when running the stored proc.  It executes but the date
>> > that is written to the table is '1899-12-31 00:00:00.000' not
>> > NULL.
>> >
>> > If anyone has any other ways ideas I would appreciate hearing
>> > them.
>> >
>> > Leonard Moss
>> >
>> > "Fridgerator" <lmoss@srcpmw.com> wrote:
>> >>
>> >>I must be missing something but OleVariant(VT_NULL) is not assignable
> to:
>> >>
>> >>mADOStoredProc->Parameters->ParamByName("@DtConfirmed")->Value
>> >>
>> >>I'm assuming that is what you meant by your reply.  Does the parameter
>> >>need to be defined as DateTime or String or some other type in order 
>> >>for
>> >>this to occur.  I tried Variant(VT_NULL) but this gave the same
> erroneous
>> >>results for the date.
>> >>
>> >>Leonard Moss
>> >>
>> >>"Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote:
>> >>>NULL is integer with value 0 in C++. You should set OleVariant with
> type
>> >>>VT_NULL.
>> >>>
>> >>>
>> >>>"Fridgerator" <lmoss@srcpmw.com> �������/�������� � �������� 
>> >>>���������:
>> >>>news:4207da7b$1@newsgroups.borland.com...
>> >>>>
>> >>>> Environment:
>> >>>>
>> >>>> C++ Builder 6
>> >>>> MS SQL Server
>> >>>> Table Column allows null.
>> >>>>
>> >>>> Using TADOStoredProc
>> >>>>
>> >>>> I create a parameter:
>> >>>>
>> >>>> mADOStoredProc->Parameters->CreateParameter("@DtConfirmed",
> ftDateTime,
>> >>>> pdInput, 8, NULL);
>> >>>>
>> >>>> I assign a NULL value
>> >>>>
>> >>>> mADOStoredProc->Parameters->ParamByName("@DtConfirmed")->Value =
> NULL;
>> >>>>
>> >>>> When I execute the stored procedure it is successful.  The problem
> lies
>> >>>> in
>> >>>> the fact that the field I want to be NULL now contains a default
> date.
>> >>>> '1899/12/30'
>> >>>>
>> >>>> If I change the above create parameter statement to:
>> >>>>
>> >>>> mADOStoredProc->Parameters->CreateParameter("@DtConfirmed", 
>> >>>> ftString,
>> >>>> pdInput, 50, NULL);
>> >>>>
>> >>>> and assign it to:
>> >>>>
>> >>>> mADOStoredProc->Parameters->ParamByName("@DtConfirmed")->Value = "";
>> >>>>
>> >>>> Execute the stored proc the value for this field is now the sql
> default
>> >>>> date:
>> >>>> '1900/01/01'
>> >>>>
>> >>>> What I really want is for this parameter to set to NULL in the 
>> >>>> table.
>> >>>> Is
>> >>>> there anyway to pass this via a stored procedure parameter so that
> the
>> >>>> value in the table is NULL.  I have tried varied attemps to pass 
>> >>>> NULL
>> >>>> and
>> >>>> other things but short of modifying the stored proc to look to see 
>> >>>> if
>> >>>> the
>> >>>> value is some default date and explicitly writing setting the field
> to
>> >>>> NULL I cannot figure out how this can be done programtically.
>> >>>>
>> >>>> Any help would be appreciated.
>> >>>>
>> >>>> Leonard Moss
>> >>>> lmoss@srcpmw.com
>> >>>>
>> >>>>
>> >>>
>> >>>
>> >>
>> >
>>
>>
>
> 
Technical Details
Message-ID: <421b2d54$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4207da7b$1@newsgroups.borland.com> <4207dc0e@newsgroups.borland.com> <4208f0a4$1@newsgroups.borland.com> <4208fef3$1@newsgroups.borland.com> <42093573@newsgroups.borland.com> <421af267@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,c5cad520fb3a6714
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <4207da7b$1@newsgroups.borland.com> <4207dc0e@newsgroups.borland.com> <4208f0a4$1@newsgroups.borland.com> <4208fef3$1@newsgroups.borland.com> <42093573@newsgroups.borland.com> <421af267@newsgroups.borland.com>
Subject: Re: Problem still Occurring - Any ideas?
Date: Tue, 22 Feb 2005 16:02:11 +0300
Lines: 157
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 85.93.137.24
Message-ID: <421b2d54$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1109077332 85.93.137.24 (22 Feb 2005 05:02:12 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail