Article View: borland.public.cppbuilder.database.ado
Article #824Re: Setting Query Parameters to a NULL string
From: Stephen Craig
Date: Fri, 27 May 2005 00:37
Date: Fri, 27 May 2005 00:37
46 lines
2640 bytes
2640 bytes
Hi Ondrej,
Thanks for the reply
If I use quotes as you described (either single or double (\")) as follows
INSERT INTO myTable (MyField, field2) VALUES (':MyField', ':field2')
and I attempt to set parameters using
qry->Parameters->ParamByName("MyField")->Value = "";
Then I get the error
Parameter 'MyField' not found
Interestingly, if I revert back to
INSERT INTO myTable (MyField, field2) VALUES (:MyField, :field2)
and set the parameter to some string and then set it to a NULL then it all
is ok. ie...
qry->Parameters->ParamByName("MyField")->Value = "dummy";
qry->Parameters->ParamByName("MyField")->Value = "";
This works perfectly
I can only imagine that the first assignment is setting some parameter
property. Initially I thought that this would be the DataType property.
But setting this to ftString prior to the NULL assignment ie...
qry->Parameters->ParamByName("MyField")->DataType = ftString;
qry->Parameters->ParamByName("MyField")->Value = "";
makes no difference. I get the same old exception ...
[Microsoft][ODBC Microsoft Access Driver]Invalid precision value.
I also tried setting the parameter Attributes to paNullable
qry->Parameters->ParamByName("MyField")->Attributes << paNullable;
Still get exception
I think I'll just have to use the dummy assignment, unless anyone can come
up with a better answer
Steve
"Ondrej Gratz" <gratzo@atlas.cz> wrote in message
news:4294958b@newsgroups.borland.com...
> Enclose string parameters in quotation marks...
>
> INSERT INTO myTable (MyField, field2) VALUES (":MyField", ":field2")
>
> Sincerely
> Ondrej Gratz
>
Technical Details
Message-ID:
<42966bb3$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<428c1ce6$1@newsgroups.borland.com> <4294958b@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,5acac13d62ebf4f7 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Stephen Craig" <stevecraig@ozemail.com.au> Newsgroups: borland.public.cppbuilder.database.ado References: <428c1ce6$1@newsgroups.borland.com> <4294958b@newsgroups.borland.com> Subject: Re: Setting Query Parameters to a NULL string Date: Fri, 27 May 2005 10:37:10 +1000 Lines: 48 Organization: Cubic Software X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 203.103.62.191 Message-ID: <42966bb3$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1117154227 203.103.62.191 (26 May 2005 17:37:07 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.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