|
Miscellany - This time I will cover some miscellaneous stuff about the database programming.
When your connections or queries fail, it obviously would be nice to know why. There are several methods for getting some error info from query and transaction object.
WString msg;
if (!query_1->Open()) {
query_1->GetErrorInfo( &msg );
msg = "Error "+msg+" occurred on query +"query_1->GetSQL();
}
// Code example lifted from the Power++ Programmer's Guide
WDataErrorArray errList=transaction_1->GetErrorList();
for (WInt i = 0; i < errList.GetCount(); i++ ) {
WLong errCode = errList[i].GetErrorCode();
WString errMsg = errList[i].GetErrorMessage();
WLong funcCode = errList[i].GetFunctionCode();
WLong natCode = errList[i].GetNativeCode();
WString state = errList[i].GetSQLState();
// then do something with these values
}
As I touched on in previous chapters in this series, you may come across the need to make your applications portable across various database systems. There are a couple of points to keep in mind:
If you keep these two points in mind, your applications should port for any DBMS (I have personally tested this from Paradox to MS SQL DBMS's).
If you have any questions or suggestions for topics, feel free to e-mail them directly to me at dosten(at)earthlink.net.
Until next time...