MFC/ODBC notes


  1. You'll need "MFC compatible" compiler :). Ok, this is not only Microsoft Visual C++, but you can use Borland C++ Builder (with installed MFC support) as well. Possibly there are other compilers that may support MFC.
  2. You need to make console application, with MFC support.
  3. Debug: I try to make debug process possible. "port.h" include code necessary for this, but I have no many experience with Visual C++.
  4. MFC initialization at start. If you are not friendly with MFC, I'll tell you that you need to initialize MFC at start of your application. I already do the function in "port.h". You may see example in dbtest test application.


For configuring the driver, you'll need to provide CONNECTIONSTRING. CONNECTIONSTRING is ODBC ability. It contain ODBC DSN, database USER and PASS, extra database parameters etc.

For understanding of this, and for easy working I mad a program named "o_param" (or "odbc_param"). It is included in distribution.

When you start it a ODBC select DSN dialog pop-up. When you select a DSN, you'll be asked for extra parameters (such as login name...). When connection is established the program prints CONNECTIONSTRING, database name (you don't need it) and database transaction support (you don't need it).


Sometimes CONNECTIONSTRING begins with "ODBC;". You do not need this text. An example string:
"ODBS;DSN=db" - real string is only "DSN=db"

My meaning of MFC/ODBC w/s BDE

BDE has better support for all supported databases, but BDE executables is large (size + 500 KB) and needs of large BDE library (10 MB) installed on same PC. Redistribution of this lib is very difficult, probably you'll need to make some installer, such Install Shield.

Sometimes BDE make large temp files, and then do not clear/delete them. This mean your work directory needs to be reviewed from time to time.

ODBC is small and it need 2-3 external DLLs. You can make static linking of these DLLs into your executable. Then executable will be large about (size + 100 KB). You'll need of ODBC driver, but you may be sure that driver already IS ON TARGET system. If it is NOT, you'll need to install it from "driver manufactured setup" (e.g. you'll do not need to make any setup program).

Microsoft ODBC driver for dBase database and similar formats supports very fair SQL, so I recommend you to find better ODBC drivers for these formats. A good idea is to use drivers from different companies (for those formats of course). 

My recommendation is to work with ODBC if you work with strong databases, and work with BDE with fair file formats such as dBase, Paradox, Text etc.