if you add the line:
#include <afxdb.h>
to your stdafx.h file, you'll have access to all the MFC database connectivity functionality. You can then use CDatabase to connect:
CDatabase myDb;
if(myDb.Open(NULL))
{
//do stuff
}
You may want to make your CDatabase object a member of your application class, that way, you can access it from anywhere in the app by adding a get fuction to return a pointer to the database (GetDb(), or something like that).
CDatabase::Open(), when called with just NULL in the parameter list will display the standard ODBC connection dialog, allowing the user to select a datasource to connect to.
If you want to select the datasource from within the program, you'll need to do it the following way:
myDb.Open(lpszDSN, bExclusive, bReadOnly, lpszConnect, bUseCursorLib))
in this example, the parameters have the following values:
lpzDSN = ""
bExclusive = FALSE
bReadOnly = FALSE
lpszConnect = Connect string, something like "ODBC;DSN=MyDsn..." this will also contain things like username and password; it depends on the ODBC Driver and the database security
bUseCursorLib = FALSE
hope this helps
CMR