Information générale
Catégorie:
Fonctions Windows API
Titre:
Adding a DSN programatically
Following an article found on UT, I have tried the following code to add a FoxPro free table dsn. It returns 0, but I don't see the dsn in the ODBC connections in Control Panel. Can anyone help me out? Thanks kindly.
#define ODBC_ADD_DSN 1
#define ODBC_CONFIG_DSN 2
#define ODBC_REMOVE_DSN 3
#define ODBC_ADD_SYS_DSN 4
#define ODBC_CONFIG_SYS_DSN 5
#define ODBC_REMOVE_SYS_DSN 6
#define ODBC_REMOVE_DEFAULT_DSN 7
#define SQL_NO_DATA 100
#define SQL_SUCCESS_WITH_INFO 1
#define SQL_SUCCESS 0
#define SQL_ERROR -1
DECLARE Integer SQLConfigDataSource IN odbccp32.dll Integer, Short, String @, String @
lc_dsn="dsn=testdsn"+ CHR(0) + ;
"DRIVER=Microsoft Visual FoxPro Driver (*.dbf)"+ CHR(0) + ;
"UID="+ CHR(0) + ;
"Deleted=Yes"+ CHR(0) + ;
"Null=Yes"+ CHR(0) + ;
"Collate=Machine"+ CHR(0) + ;
"BackgroundFetch=Yes"+ CHR(0) + ;
"Exclusive=No"+ CHR(0) + ;
"SourceType=DBF"+ CHR(0) + ;
"SourceDB=c:\SSPDF"+ CHR(0)
fResult = SQLConfigDataSource(0, ODBC_ADD_DSN, @lc_driver, @lc_dsn)
? fresult
Gerry Lamb
Newkirk Products, Inc.
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement