Thread View: borland.public.cppbuilder.database.ado
3 messages
3 total messages
Started by siraj
Thu, 02 Mar 2006 08:16
Field cannot be modified error
Author: siraj
Date: Thu, 02 Mar 2006 08:16
Date: Thu, 02 Mar 2006 08:16
31 lines
1726 bytes
1726 bytes
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
Re: Field cannot be modified error
Author: 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();
Re: Field cannot be modified error
Author: siraj
Date: Fri, 03 Mar 2006 15:09
Date: Fri, 03 Mar 2006 15:09
48 lines
2816 bytes
2816 bytes
Thank you for the reply.
It works if the following line is added before the line
ADOQuery1->FieldByName("id")->AsInteger = 2 ;
ADOQuery1->FieldByName("id")->ReadOnly = false;
So
ADOQuery1->Insert();
ADOQuery1->FieldByName("id")->ReadOnly = false;
ADOQuery1->FieldByName("id")->AsInteger = 2 ;
ADOQuery1->FieldByName("Name")->AsString = "sms";
ADOQuery1->Post();
I am using windows xp sp2 which has MDAC 2.8 sp1 and c++ builder 2006.
I had a c++ bulder 5 program using MDAC 2.8 that I am now converting to c++
builder 2006 project.
There are some issues with respect to using server side cursors in MDAC 2.8
sp1.
I get the error "Provider cannot determine the value. Possible reasons: the
record was just created, the default value for the field was not available,
or the user has not set a new value." when using server side cursor with
batch optimistic mode. If I change the cursor to client side then I do not
get the error. The only way I can used the server side cursor without error
is to use it with optimistic lock.
Storing using client side cursor and batch optimistic lock is 11 times
slower compared to server side cursor with optimistic lock for 5000 values.
I have seen that storing using server side cursor with batch optimistic lock
is faster in c++ builder 5 and MDAC 2.8.
How to use the server side cursor with batch optimistic lock in windows xp
sp2 and MDAC 2.8 sp1?
My main intention is to reduce the storing time as I have to store large
number of values.
"Adriano Grandi" <adriano@cedepp.it> wrote in message
news:440721c0@newsgroups.borland.com...
>
> You must use:
> ADOQuery1->Insert();
> ADOQuery1->FieldByName("id")->AsInteger = 2 ;
> ADOQuery1->FieldByName("Name")->AsString = "sms";
> ADOQuery1->Post();
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads