C++Interface: How to trap error message from conn.Open(database)
Posted in 2003
Topics: Security, Permissions & Auditing
// Set Connection Info ITDBInfo database; database.SetUser(dbuser); database.SetPassword(dbpassword); database.SetSystem(dbinstance); database.SetDatabase(dbname); // Connect ITConnection conn; if ( !conn.Open(database) ) { printf("%s:Error: Failed to connect to the database\\n",dbinstance); // Would like to print error error_number:text. The message above does not // help to tell me why the connection failed }; How to trap error message from conn.Open(database). I would like to see the error message that is generated when I'm not able to connect ??
Ketil wrote: > // Set Connection Info > > ITDBInfo database; > database.SetUser(dbuser); > database.SetPassword(dbpassword); > database.SetSystem(dbinstance); > database.SetDatabase(dbname); > > // Connect > ITConnection conn; > if ( !conn.Open(database) ) > { > printf("%s:Error: Failed to connect to the database\\n",dbinstance); > // Would like to print error error_number:text. The message above > does not > // help to tell me why the connection failed > }; > > How to trap error message from conn.Open(database). I would like to > see the error message that is generated when I'm not able to connect > ?? Check global variables sqlca and SQLCODE and SQLSTATE etc? As found in ESQL/C. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/