This error message occurs only when all of the following conditions are met:
- The transaction is active.
- There is already an active command (pending resultset) and you are trying to run another command in the same session/connection.
- The pending resultset is associated with forward-only and read-only cursor (also known as firehose or default resultset).
- The DBPROP_MULTIPLECONNECTIONS property on the data source is set to VARIANT_TRUE.
Following is an excerpt from a Microsoft Knowledge Base article (Q271128--see the "References" section):
Note You must change User ID <username> and password =<strong password> to the correct values before you run this code. Make sure that User ID has the appropriate permissions to perform this operation on the database
int main(int argc, char* argv)
CCommand<CNoAccessor, CNoRowset> command2;
hr = CoInitialize(NULL);
cout << "Could not initialize COM" << endl;
hr = DataSource.OpenFromInitializationString(L"Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=MSSQLServer01;"
L"User ID=<user name>;password=<strong password>;Initial Catalog=Pubs;");
cout << "Could not connect to SQL Server" << endl;
hr = Session.Open(DataSource);
cout << "Could not create session" << endl;
hr = command1.Open(Session,"SELECT * FROM pubs..authors");
cout << "Could not open rowset associated with command1" << endl;
// At this point, the first resultset is still pending and you are trying to execute another command.
// (Table TAB1 has a single INT type column)
hr=command2.Open(Session, "INSERT INTO pubs..TAB1 VALUES(100)", NULL , NULL, DBGUID_DBSQL, false);
if (FAILED(hr)) myErrHandler();
ULONG numRec = 0;
ISQLErrorInfo *pISQLErrorInfo = NULL;
LCID lcLocale = GetSystemDefaultLCID();
cout << "Error Message:" << (_bstr_t)(myErrStr) << endl;
Article ID: 272358 - Last Review: Aug 4, 2008 - Revision: 1