var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Fail to execute SQL command asynchronously
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->Open (strCnn, "", "", adConnectUnspecified);
// Create command object.
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
It more likely means you can not issue multiple asynchronous commands on the same command object. If the previous command's state is "running" (can't remember offhand what the actual code/value is), then the command object should choke.
Tags for this Thread