๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.multi-tier
1 messages
1 total messages Started by mlesage Mon, 02 Jul 2001 13:29
ADO COM+ MTS UpdateBatch
#539
Author: mlesage
Date: Mon, 02 Jul 2001 13:29
58 lines
2274 bytes
The following piece of code (a Transactional Object)
works fine when it isn't the component isn't added to a COM+ application.

When added, the changes made to the database through updatebatch
aren't committed.

Does anybody have a clue how this comes ?
It would help me a lot.

When i look at the statistics of COM+ it appears as if the transaction succeeded.

--------- CODE : ------------
STDMETHODIMP TTYRAImpl::ReturnRS(LPDISPATCH* Rs)
{
  try
  {
    TCOM_Recordset adoRs = CoRecordset::Create();
    adoRs->CursorLocation = adUseClient;
    adoRs->Open( "SELECT * FROM Customers", "DSN=North", adOpenStatic,
      adLockBatchOptimistic, adCmdText );
    *Rs = (IDispatch*)adoRs;
    adoRs->AddRef();
    return S_OK;
  }
  catch (...)
  {
    ShowMessage("Return Problem !");
  }
  return E_FAIL;
}


STDMETHODIMP TTYRAImpl::UpdateRs(LPDISPATCH Rs)
{
  _Recordset* rs;
  try
  {
      Rs->QueryInterface(__uuidof(Recordset), (void**)&rs);

      TCOM_Connection cn = CoConnection::Create();
      cn->ConnectionString = L"DSN=North";
      cn->CursorLocation = adUseClient;
      cn->Open(L"", L"", L"", -1);
      rs->ActiveConnection = cn;
      rs->UpdateBatch(adAffectAll);
      rs->Release();
      m_spObjectContext->SetComplete();
  }
  catch(...)
  {
    ShowMessage("Update Problem !");
    m_spObjectContext->SetAbort();
  }
  return S_OK;
}

Micha๏ฟฝlo Lesage.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads