Re: lengthy operation



Thanks Stephen for your help, I will try this and I will look at the batch
process too ... :)

"Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom> wrote in message
news:eG1J97MDHHA.572@xxxxxxxxxxxxxxxxxxxxxxx
Which command can I use to insert a record in table ? my problem is when
I
open the recordset associated with the table (thousands of records), it
takes very long time. But I don't want to get all records, I only want to
add a new one.

I used the following code to open the recordset :
pRecordSet->Open("table", pConnection, true, adOpenKeyset,
adLockOptimistic,
acCmdTable);

I use VC7.1 and ADO. I have used ADO since 1999 while I have not used
everything as there is probably quite a few gaps in my knowledge, I know a
tiny bit.

As Bob says. You want

pRecordSet->Open("SELECT * FROM yourtable WHERE 0=1", pConnection, true,
adOpenKeyset, adLockOptimistic, adCmdText);
or
pRecordSet->Open("SELECT field1,field2,field3 FROM yourtable WHERE 0=1",
pConnection, true, adOpenKeyset, adLockOptimistic, adCmdText);

where you specify all the fields. The 0=1 is the only way of starting with
0
records. Setting MaxRecords to 0 wont work (0 is regarded as a special).

Often if I am just populating a table with new records I will open this
Client-sided and UpdateBatch mode as ADO is optimised to populate waves of
records reasonably fast.

Stephen Howe




.



Relevant Pages