๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #5196

ADO COM+ MTS UpdateBatch

#5196
From: mlesage
Date: Mon, 02 Jul 2001 13:25
58 lines
2266 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.
Technical Details
Message-ID: <3b40764c_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.he.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10698b,9cc960358f3aa2d,start
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2001-07-02 06:33:59 PST
From: "mlesage" <michaelo_lesage@hotmail.com>
Sender: "mlesage" <michaelo_lesage@hotmail.com>
Reply-To: "mlesage" <michaelo_lesage@hotmail.com>
Subject: ADO COM+ MTS UpdateBatch
Newsgroups: borland.public.cppbuilder.database.ado
X-User-Info: 194.78.30.90 194.78.30.90    
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3b40764c_2@dnews>
Date: 2 Jul 2001 06:25:32 -0700
X-Trace: dnews 994080332 207.105.83.65 (2 Jul 2001 06:25:32 -0700)
Lines: 58
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.he.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews