1. Create an EXE file based on the dialog box
2. Add in stdafx. h
# Include <afxdb. h>
# Include <afxtempl. h>
3. Add:
# Include <odbcinst. h>
# Import "C: \ Program Files \ common files \ System \ ADO \ msado15.dll" RENAME ("EOF", "adoeof ")
Using namespace ADODB;
Typedef bool (winapi * sqlconfigdatasource_function) (hwnd, word, lpcstr, lpcstr );
4. Add:
Hinstance H =: loadlibrary ("odbccp32.dll ");
: Sqlconfigdatasource_function pconfigdatasource = 0;
Pconfigdatasource = (sqlconfigdatasource_function) getprocaddress (H, "sqlconfigdatasource ");
// Use the dynamic path to set the ODBC Data Source
Char sdirectory [256];
: Getcurrentdirectory (256, sdirectory );
Strcat (sdirectory, "\ student. mdb ");
Char ss [256] = "DSN = studb0dbq = ";
Strcat (SS, sdirectory );
Ss [9] = 0; // distinguish between front and back substrings
Int length = strlen (SS );
Ss [length] = 0; // because this parameter ends with a dual Terminator
Bool res = pconfigdatasource (null, odbc_add_dsn, "Microsoft Access Driver (*. mdb)", SS );
: Freelibrary (h); // release dynamic Connection Library Resources