Article View: borland.public.cppbuilder.database.ado
Article #826Re: Setting Query Parameters to a NULL string
From: Viatcheslav V. Vassiliev
Date: Fri, 27 May 2005 09:49
Date: Fri, 27 May 2005 09:49
66 lines
3495 bytes
3495 bytes
> [Microsoft][ODBC Microsoft Access Driver]Invalid precision value.
Switch to Jet OLEDB provider - it is native for Access and is better than
OLEDB provider for ODBC that you use now. Connection string is:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydb.mdb;
//------------------------------------------
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)
"Stephen Craig" <stevecraig@ozemail.com.au> �������/�������� � ��������
���������: news:42966bb3$1@newsgroups.borland.com...
> 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:
<4296ed4a@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<428c1ce6$1@newsgroups.borland.com> <4294958b@newsgroups.borland.com> <42966bb3$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,5acac13d62ebf4f7 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <428c1ce6$1@newsgroups.borland.com> <4294958b@newsgroups.borland.com> <42966bb3$1@newsgroups.borland.com> Subject: Re: Setting Query Parameters to a NULL string Date: Fri, 27 May 2005 13:49:57 +0400 Lines: 68 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 NNTP-Posting-Host: 85.93.138.132 Message-ID: <4296ed4a@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1117187402 85.93.138.132 (27 May 2005 02:50:02 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail