Article View: borland.public.cppbuilder.database.ado
Article #434Re: Field cannot be modified error
From: Adriano Grandi
Date: Thu, 02 Mar 2006 16:47
Date: Thu, 02 Mar 2006 16:47
41 lines
2033 bytes
2033 bytes
"siraj" <siraj.sm@omnisens.ch> ha scritto nel messaggio
news:4406a9d4@newsgroups.borland.com...
> Hi,
> I am now using C++ builder 2006 and MS acccess 2003.
> I have simple table Table1 in Access with the following fields. This table
> is linked to other table.
> 1) id autonumber
> 2) Name String
>
> I have to add nearly 10000 rows to the table.
> I have to also insert into the 'id' field.
>
> I am using TADOQuery to insert.
> If I use,
> INSERT INTO Table1(id,Name) VALUES(2,"sms")
> ExecSQL()
> there is no problem.
>
> If I use,
> ADOQuery1->Insert();
> ADOQuery1->FieldValues["id"]=2 ;
> ADOQuery1->FieldValues["Name"]="sms";
> ADOQuery1->Post();
> I get the error "Field 'id' cannot be modified".
>
> Why?
>
> Insert into the dataset is faster compared to using ExecSQL() 10000 times.
>
> Please help.
>
> Regards,
> Siraj
>
You must use:
ADOQuery1->Insert();
ADOQuery1->FieldByName("id")->AsInteger = 2 ;
ADOQuery1->FieldByName("Name")->AsString = "sms";
ADOQuery1->Post();
Technical Details
Message-ID:
<440721c0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4406a9d4@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,a7a9d6e24de244a5 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Adriano Grandi" <adriano@cedepp.it> From: "Adriano Grandi" <adriano@cedepp.it> Newsgroups: borland.public.cppbuilder.database.ado References: <4406a9d4@newsgroups.borland.com> Subject: Re: Field cannot be modified error Date: Thu, 2 Mar 2006 17:47:51 +0100 Lines: 43 Organization: Cedepp srl X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 82.189.222.98 Message-ID: <440721c0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1141318080 82.189.222.98 (2 Mar 2006 08:48:00 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail