ODBC Traps and Pitfalls

The code presented in this chapter is designed to use the ODBC version 3-compatible functions. In theory, the applications created using this class should work even if the driver does not understand ODBC version 3, by transparently mapping ODBC version 3 functions to the ODBC version 2 functions. Mapping seems like a good idea, but in practice it is less than perfect. At least one recently released ODBC-compatible DBMS does not support the version 3 semantics and will not allow version 3 applications to run correctly. This can become a major problem, which might require you to maintain an older version of the class for use with the non- complying applicationand at the same time maintain a newer version that will fully exploit the features the latest ODBC has to offer.

Additionally, the lack of data type standardization can lead to problems. Even in the simple example presented in Listing 8-1, dependencies on date formats would likely require minor application modifications before the application would work properly with other ODBC-compliant databases. The need to make changes to accommodate data type differences between ODBC data sources is not ideal, and it can cause tremendous difficulties when moving an ostensibly data-neutral ODBC application from one database to another. Number representation is another potential trouble area.

Another important task for developers of server applications is ensuring that the ODBC driver does not present a user interface and display message boxes, but rather notifies the application program of errors directly. Testing for this error notification is important if the vendor cannot or will not certify that the driver is without a UI. The problems can be subtle. For instance, one ODBC driver required for a recent project appeared to meet the criteria because errors seemed to properly generate return codes that indicated errors had occurred. Unfortunately, when the ODBC API functions were used to gather diagnostic information concerning errors that occurred, it was discovered that the driver did generate a message box.

In limited cases, some drivers might generate message boxes for only certain classes of errors. Perhaps in these situations, the developer of the driver considered it impossible to propagate the error code without showing a message box.



Inside Server-Based Applications
Inside Server-Based Applications (DV-MPS General)
ISBN: 1572318171
EAN: 2147483647
Year: 1999
Pages: 91

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net