Click here to Skip to main content
15,921,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help with unmananged dlls Pin
eggie518-Oct-06 15:57
eggie518-Oct-06 15:57 
GeneralRe: Help with unmananged dlls Pin
eggie518-Oct-06 16:01
eggie518-Oct-06 16:01 
Question4TH ORDER RUNGE-KUTTA ALGORITHM Pin
sahoong18-Oct-06 8:53
sahoong18-Oct-06 8:53 
AnswerRe: 4TH ORDER RUNGE-KUTTA ALGORITHM Pin
David Crow18-Oct-06 9:10
David Crow18-Oct-06 9:10 
AnswerRe: 4TH ORDER RUNGE-KUTTA ALGORITHM Pin
Christian Graus18-Oct-06 12:21
protectorChristian Graus18-Oct-06 12:21 
GeneralRe: 4TH ORDER RUNGE-KUTTA ALGORITHM Pin
sahoong19-Oct-06 5:50
sahoong19-Oct-06 5:50 
AnswerRe: 4TH ORDER RUNGE-KUTTA ALGORITHM Pin
JWood18-Oct-06 15:08
JWood18-Oct-06 15:08 
QuestionHandling exception Pin
Demian Panello18-Oct-06 5:59
Demian Panello18-Oct-06 5:59 
I'm developing a MFC application using ADO to connect to a local SQL Server database.
And I have troubles catching the exceptions.
Here is my connection code:


const LPCSTR STRING_CONNECTION = "Provider=SQLOLEDB;User ID=sa;Initial Catalog=Northwind;Data Source= (local); Integrated Security=SSPI;";
<br />
BOOL Connect(_ConnectionPtr& pCone)<br />
{<br />
_bstr_t bstrCone(STRING_CONNECTION); <br />
<br />
try<br />
{<br />
<br />
pCone.CreateInstance (__uuidof(Connection));<br />
<br />
// If the following line fails, I can't handling the error<br />
pCone->Open (bstrCone ,_bstr_t (""), _bstr_t (""), adModeUnknown );<br />
<br />
return TRUE;<br />
}<br />
catch (_com_error* ce) // NEVER reach that catch, even forcing an error.<br />
{<br />
watch_com_error(ce); <br />
return FALSE;<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
void watch_com_error(_com_error *e)<br />
{<br />
CString msgErr; <br />
_bstr_t bstrSource= e->Source(); <br />
_bstr_t bstrDescri=e->Description(); <br />
<br />
msgErr.Format (_T("ADO - COM Error\n\tCode = %08lx\n\tSource = %s\n\tDescription = %s\n"),<br />
e->Error(),(LPCSTR)bstrSource, (LPCSTR)bstrDescri);<br />
<br />
msgErr.Format (_T("ADO - COM Error\n\tCode = %08lx\n\tSource = %s\n\tDescription = %s\n"),<br />
e->Error(),(LPCSTR)bstrSource, (LPCSTR)bstrDescri);<br />
<br />
AfxMessageBox( msgErr, MB_OK | MB_ICONERROR );<br />
<br />
}<br />
<br />
<br />





The connection works. The problem is handling exceptions.

If I change the string connection to force a COM ERROR, it throw an unhandled exception instead of reach the _com_error handle.
And if I change the _com_error catch by a CException object to intercept generics exceptions, it still throwing an unhandled exception.
What is wrong here?


Demian.

"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."

-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )

AnswerRe: Handling exception Pin
Zac Howland18-Oct-06 6:26
Zac Howland18-Oct-06 6:26 
GeneralRe: Handling exception Pin
Demian Panello18-Oct-06 7:11
Demian Panello18-Oct-06 7:11 
QuestionFOURTH-ORDER RUNGE-KUTTA ALGORITHM Pin
sahoong18-Oct-06 5:57
sahoong18-Oct-06 5:57 
AnswerRe: FOURTH-ORDER RUNGE-KUTTA ALGORITHM Pin
Mark Salsbery18-Oct-06 6:46
Mark Salsbery18-Oct-06 6:46 
AnswerRe: FOURTH-ORDER RUNGE-KUTTA ALGORITHM Pin
David Crow18-Oct-06 8:07
David Crow18-Oct-06 8:07 
AnswerRe: FOURTH-ORDER RUNGE-KUTTA ALGORITHM Pin
Chris Losinger18-Oct-06 8:18
professionalChris Losinger18-Oct-06 8:18 
GeneralRe: FOURTH-ORDER RUNGE-KUTTA ALGORITHM Pin
Jörgen Sigvardsson18-Oct-06 11:32
Jörgen Sigvardsson18-Oct-06 11:32 
Questiontcp receive Pin
Archyami18-Oct-06 5:22
Archyami18-Oct-06 5:22 
AnswerRe: tcp receive Pin
Mark Salsbery18-Oct-06 5:28
Mark Salsbery18-Oct-06 5:28 
GeneralRe: tcp receive Pin
Archyami18-Oct-06 6:58
Archyami18-Oct-06 6:58 
GeneralRe: tcp receive Pin
Mark Salsbery18-Oct-06 7:02
Mark Salsbery18-Oct-06 7:02 
GeneralRe: tcp receive Pin
Archyami18-Oct-06 7:14
Archyami18-Oct-06 7:14 
QuestionNetwork Protocol Analyzer? Pin
Andy Rama18-Oct-06 3:07
Andy Rama18-Oct-06 3:07 
AnswerRe: Network Protocol Analyzer? Pin
Mark Salsbery18-Oct-06 6:58
Mark Salsbery18-Oct-06 6:58 
Questionowner darw & xp theme problem Pin
314159265318-Oct-06 2:45
314159265318-Oct-06 2:45 
AnswerRe: owner darw & xp theme problem Pin
Jörgen Sigvardsson18-Oct-06 11:38
Jörgen Sigvardsson18-Oct-06 11:38 
Questionfinding type of device connected to USB port Pin
pavan_sw18-Oct-06 2:31
pavan_sw18-Oct-06 2:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.