Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a VFP ODBC DSN Programmatically..
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00313899
Message ID:
00313942
Vues:
63
Jon:

Here it is, I copied it from the article:


You can also create the ODBC data source programmatically. See the Microsoft knowledge base article on how this is done http://support.microsoft.com/support/, then search for article Q142216 which gives 2 non-Oracle examples. This is the only example I know of, but it should be sufficient as a starting point to trying this method for an Oracle data source. What has worked for me is the following.


--------------------------------------------------------------------------------


lparameters lcODBCDriver, lcSettings
*
* 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.)
--------------------------------------------------------------------------------

The third parameter in SQLConfigDataSource must be the exact driver name from the ODBC Administrator. In my case, we are using the MS 32-bit ODBC driver. The actual name you have to use for this driver is Microsoft ODBC for Oracle. Success is equal to 1 if successful, Zero if it fails. This function will automatically add 4 entries or more in the registry - the 3 listed above and the appropriate MS ODBC DLL file the ODBC driver uses. The number of entries depends on the number of parameters defined in the listings parameter. You should use the ODBC Administrator to create one yourself, then look in the registry to see what parameters were defined. Look in HKEY_CURRENT_USER\Software\ODBC\ODBC.INI of the registry.

At this point, you should now have a TCP/IP address for your workstation (this is left up to your Network Administrator to do), and have installed SQL*Net and the MS ODBC drivers. Your Oracle data source has been defined either manually through the ODBC Administrator or programmatically. You are now ready to launch VFP and start developing or upsizing your front-end application using an Oracle database.

Microsoft has an on-line Knowledge Base at http://support.microsoft.com/support/ which has much information on ODBC and Oracle. On this search page, I would select ODBC in Step 1, and type in Oracle in Step 5. The search engine will return all the pertinent articles. Good luck!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform