Article View: borland.public.cppbuilder.database.ado
Article #949Null DateTime Problem Resolved.
From: Fridgerator
Date: Fri, 11 Feb 2005 16:23
Date: Fri, 11 Feb 2005 16:23
77 lines
2929 bytes
2929 bytes
Thanks for the help from Viatcheslav V. Vassiliev and Matt Jacobs.
Either of the following works:
Declare this:
OleVariant vNull;
vNull.VType = VT_NULL;
Assign here:
mADOStoredProc->Parameters->CreateParameter("@DtConfirmed", ftDateTime, pdInput, 8, vNull);
or:
Declare this:
Variant vNull;
vNull.ChangeType(varNull);
Assign here:
mADOStoredProc->Parameters->CreateParameter("@DtConfirmed", ftDateTime, pdInput, 8, vNull);
or here:
tParams->ParamByName("@DtConfirmed")->Value = vNull;
Both methods result in a null value being written to the database field and thankfully and end to my problem.
Thanks again,
Leonard S. Moss
"Fridgerator" <lmoss@srcpmw.com> wrote:
>
>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:
<420cdbef$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4207da7b$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,c5cad520fb3a6714 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Fridgerator" <lmoss@srcpmw.com> Sender: "Fridgerator" <lmoss@srcpmw.com> Reply-To: "Fridgerator" <lmoss@srcpmw.com> Subject: Null DateTime Problem Resolved. Newsgroups: borland.public.cppbuilder.database.ado X-User-Info: 205.169.209.234 References: <4207da7b$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <420cdbef$1@newsgroups.borland.com> Date: 11 Feb 2005 08:23:11 -0800 X-Trace: newsgroups.borland.com 1108138991 207.105.83.66 (11 Feb 2005 08:23:11 -0800) Lines: 78 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail