Error handling in C++(ADO)

W

Wolfgang Unger

Hi,
im not this experienced in C++(Java is
my background..) and
now I'm really needing some help...
I don't know how to catch an Exception
in a database test-programm (C++Builder).
I'm opening a database(access) with a TADOConnection, which
is fine, when the connection-string is ok.
But I want to take care of the situation the path(maybe from a ini-file)
is wrong.
When testing this, I always get an EOleException-Popup.
The following code didn't work(I tried more than this, nothing
worked!!)
For example, when asking for 'if(!con1->Connected )' I already
get the exception popup.
Trying to catch a EOleException won't work(type name expected...)
Thanks for any help!
------------
try{
con1->ConnectionString =
"D:\\programming\\c++\\wu\\cbuilder\\tests\\db\\db\\db1.mdb";
con1->Provider = "Microsoft.Jet.OLEDB.4.0";
con1->Open() ;
if(!con1->Connected ){
throw Exception("Shit");
}
catch(EADOError &err){
ShowMessage(err.Message );
return false;
}
catch(Exception &e){
ShowMessage(e.Message );
return false;
}

catch(...){
return false;
}
return true;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top