Hi,
I want to invoke a SQL command “INSERT INTO …” for 3, 000,
000 times to insert 3, 000, 000 records via ADO.
Other than the BULK INSERT command, I also want to utilize
the ADO.Command object to execute the SQL command asynchronously.
So I do as follows:
_bstr_t strSQLChange("INSERT INTO MyTable VALUES (1, 2, 3);");
_ConnectionPtr pConnection = NULL; _CommandPtr pCmdChange = NULL;
// Open connection.
pConnection.CreateInstance(__uuidof(Connection));
pConnection->Open (strCnn,
"", "", adConnectUnspecified);
// Create command object.
pCmdChange.CreateInstance(__uuidof(Command));
pCmdChange->ActiveConnection =
pConnection;
pCmdChange->CommandText =
strSQLChange;
for (UINT uIndex = 0; uIndex <
3000000, uIndex ++)
pCmdChange->Execute(NULL, NULL, adCmdText | adAsyncExecute | adExecuteNoRecords); The first execution is OK. But the second one will cause the following error
“Operation
cannot be performed while connecting asynchronously”
Does
that means the ADO command object cannot execute the SQL command asynchronously?
Thanks