🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: TADOStoredProc DateTime SQL Field Null Value Setting Problem

#944
From: Fridgerator
Date: Tue, 08 Feb 2005 17:02
66 lines
3125 bytes
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: <4208f0a4$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.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>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,c5cad520fb3a6714
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
From: "Fridgerator" <lmoss@srcpmw.com>
Sender: "Fridgerator" <lmoss@srcpmw.com>
Reply-To: "Fridgerator" <lmoss@srcpmw.com>
Subject: Re: TADOStoredProc DateTime SQL Field Null Value Setting Problem
Newsgroups: borland.public.cppbuilder.database.ado
X-User-Info: 205.169.209.234     
References: <4207da7b$1@newsgroups.borland.com> <4207dc0e@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4208f0a4$1@newsgroups.borland.com>
Date: 8 Feb 2005 09:02:28 -0800
X-Trace: newsgroups.borland.com 1107882148 207.105.83.66 (8 Feb 2005 09:02:28 -0800)
Lines: 67
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail