Article View: borland.public.cppbuilder.database.ado
Article #4653Re: ADO Error
From: jqpdev
Date: Wed, 24 Oct 2001 19:27
Date: Wed, 24 Oct 2001 19:27
83 lines
3696 bytes
3696 bytes
Hey Dale,
I was looking at your post and I don't totally understand exactly what
you're trying to accomplish in your code.
From what I gather this code belongs with some COM/Interface stuff that
you're implementing...
If your are not returning a dataset in your SQL statement (ex: select
emp_name from employees)...
then don't use the Open() method... use the Execute() method for ADOCommands
and ExecProc() method for stored procedures.
Here is my suggestion which is a snipped from a class:
class TTransactionExecutorOps : public TGenericOperation
{
protected:
// protected data members
TGenOperationStatusCode _ExecutionResult;
TOleExceptionAutoPtr _TheCapturedOleException;
TADOConnectionPtr _TheADOConnection;
TADOStoredProcPtr _TheADOStoredProc;
// protected methods
void GrabTheOleException( EOleExceptionRef TheOleExceptionToCaptureRef )
public:
// public methods
explicit TTransactionExecutorOps(TADOConnection*
TheConnection,TADOStoredProc* TheStoredProc)
virtual ~TTransactionExecutorOps() { ; }
//--------------------------------------------------------------------------
-------------------------------------------
//---------[the meat and potatoes of the
suggestion ]--------------------------------------------------------------
//--------------------------------------------------------------------------
-------------------------------------------
virtual void DoOperation()
{
// try to execute the transaction
try
{
// begin the transaction
// execute the ado stored procedure
// commit the transaction
_TheADOConnection->BeginTrans();
_TheADOStoredProc->ExecProc();
_TheADOConnection->CommitTrans();
// declare the operation a success
_ExecutionResult = GOSC_Success;
}
// catch ole exception here
catch( EOleException& AnOleException )
{
// store the ole exception
// roll back the transaction
GrabTheOleException( AnOleException );
_TheADOConnection->RollbackTrans();
// declare the operation a failure
_ExecutionResult = GOSC_Failure;
}
}
//--------------------------------------------------------------------------
-------------------------------------------
//---------[end of the meat and potatoes of the
suggestion ]------------------------------------------------------
//--------------------------------------------------------------------------
-------------------------------------------
virtual TGenOperationStatusCode GetExecutionResult()
{
return _ExecutionResult;
}
EOleExceptionRef GetCapturedOleExceptionRef()
{
EOleExceptionRef TheExceptionRef = *_TheCapturedOleException;
return TheExceptionRef;
}
HTH
Technical Details
Message-ID:
<3bd71561$1_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!in.nntp.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3bd57e5e_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,813b5ae544a1f3b1 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-10-24 12:38:43 PST From: "jqpdev" <jqpdev@whowhatwhere.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3bd57e5e_1@dnews> Subject: Re: ADO Error Date: Wed, 24 Oct 2001 15:27:41 -0400 Lines: 85 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 NNTP-Posting-Host: 24.185.61.176 Message-ID: <3bd71561$1_2@dnews> X-Trace: dnews 1003951457 24.185.61.176 (24 Oct 2001 12:24:17 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!in.nntp.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews