Home > Software engineering >  ADO SQL Server: why affairs ignored influence _RecordsetPtr query result??
ADO SQL Server: why affairs ignored influence _RecordsetPtr query result??

Time:05-20

Everybody is good, my code is roughly as follows:

 
Void foo ()
{
Try
{
_variant_t affected=0;
_RecordsetPtr recordset_ptr=NULL;
_ConnectionPtr connection_ptr=NULL;

Recordset_ptr. CreateInstance (__uuidof (you));
Connection_ptr. CreateInstance (__uuidof (Connection));

//open the link
Connection_ptr - & gt; Open (... )

//query execution
Connection_ptr - & gt; BeginTrans ();//1

Recordset_ptr=connection_ptr - & gt; Excute (_bstr_t (" select * from table_foo "), & amp; Affected, adCmdText);

Connection_ptr - & gt; CommitTrans ();//2

VARIANT_BOOL res=recordset_ptr - & gt; BOF.//3

.
}
The catch (_com_error & amp; E)
{
E.E rrorMessage ();
}
}


Now the situation is:
If add statements 1 and 2, namely BeginTrans () and CommitTrans (), then execute a statement 3: VARIANT_BOOL res=recordset_ptr - & gt; When the BOF
Jump straight to exception: a catastrophic failure,
If the commented-out statements 1 and 2, namely BeginTrans () and CommitTrans (), so all is well,

All this is how to return a responsibility excuse me? What principle??
  • Related