15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


AfxThrowDBException vs. ThrowDBException

Drolshagen Thomas -- TDrolshagen@messe.ch
Friday, January 03, 1997

Environment: Windows NT 4.0, VC++ 4.2b      

Hi
I've a new class CMyRecordset derived from CRecordset.
For implementing an extended error tracing I've overloaded the virtual
CRecordset::ThrowDBException in my new CMyRecordset class.
Now, my problem is that MFC-CRecordset sometimes calls the global
function AfxThrowDBException
and sometimes CRecordset::ThrowDBException. When
CRecordset::ThrowDBException is called everything is fine and I can call
my extended error tracing in CMyRecordset::ThrowDBException but when MFC
uses the global function AfxThrowDBException I've no chance to call my
own error tracing.

Is there anybody who can help or explain me why CRecordset sometimes
uses ThrowDBException and sometimes AfxThrowDBException.
(I think AfxThrowDBException should not be used in the MFC !)

Regards,
Thomas Drolshagen





Mike Blaszczak -- mikeblas@nwlink.com
Saturday, January 04, 1997

At 15:15 1/3/97 +0100, Drolshagen Thomas wrote:
>Environment: Windows NT 4.0, VC++ 4.2b      

>Now, my problem is that MFC-CRecordset sometimes calls the global
>function AfxThrowDBException and sometimes CRecordset::ThrowDBException.

CRecordset::ThrowDBException() is undocumented; it's a protected 
function under the implementation line of the class. By overriding it,
you're taking your own chances: MFC is free to do whatever it wants
to underneath the implementation line, and what it does in one version
might change in the next version.

>Is there anybody who can help or explain me why CRecordset sometimes
>uses ThrowDBException and sometimes AfxThrowDBException.
>(I think AfxThrowDBException should not be used in the MFC !)

MFC has plenty of reasons to call AfxThrowDBException(): there are many
(many!) situations where a database exception condition presents
itself and a valid CRecordset object isn't avaialble.  MFC _has_ to
call AfxThrowDBException() sometimes.

Some of the calls to AfxThrowDBException() in DBCORE.CPP are from
static members of CRecordset. Sice ThrowDBException() isn't static,
the virutal function can't be called from those static functions.

There are a handful of other situations where the function is called,
and those are questionable, and maybe we'll look at changing them
later.

.B ekiM
http://www.nwlink.com/~mikeblas/
I'm afraid I've become some sort of speed freak.
These words are my own. I do not speak on behalf of Microsoft.





| Вернуться в корень Архива |