Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Anybody been able to do this?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00381450
Message ID:
00381471
Vues:
12
>>Has anyone been able to use the SQLConfigDataSource() function to programmatically create and configure an ODBC data source for SQL Server? I have a feeling I'm real close, but...
>>
>>tia,
>
>Also make sure each setting is separated by chr(0)
>*
>* For example:
>*
>* lcODBCDriver "Microsoft ODBC for Oracle"
>* lcSettings "DSN=Locator"+chr(0);
>*              +"Description=Region 6 Locator"+chr(0);
>*              +"Server=OraServer"+chr(0);
>*              +"UID=optional"
>*
>if parameters() <> 2
>   return .f.
>endif
>if type("lcODBCDriver") <> "C" or empty(lcODBCDriver)
>   return .f.
>endif
>if type("lcSettings") <> "C" or empty(lcSettings)
>   return .f.
>endif
>if right(lcSettings, 1) <> chr(0)
>   lcSettings = lcSettings + chr(0)
>endif
>#define  ODBC_ADD_DSN            1    && included so you know what
>#define  ODBC_CONFIG_DSN         2    && can be passed as 2nd parameter
>#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
>DECLARE Integer SQLConfigDataSource in odbccp32 ;
>   Integer, Integer, String, String
>lnSuccess=SQLConfigDataSource(0,ODBC_ADD_DSN,lcODBCDriver,lcSettings)
>return iif(lnSuccess > 0, .t., .f.)
Even though I've already got this working, you've saved me the trouble of find the constants. Thanks (once more) Mark.

BTW, if you don't mind me making a suggestion for the above...I'd use RETURN (lnSuccess > 0) and save the function call. It'll work the same.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform