Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQLConfigDataSource problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00111019
Message ID:
00111050
Vues:
30
>>>>Any ideas on why the following is failing (returns 0)?
>>>>DECLARE Integer SQLConfigDataSource in odbccp32 ;
>>>>   Integer, Integer, String, String
>>>>lcODBCDriver="MSORCL32"
>>>>lcSettings="DSN=Locator"+chr(0)+;
>>>>           "Description=Region 6 Locator"+chr(0)+;
>>>>           "Server=Reg6"+chr(0)+;
>>>>           "UID=Reader"
>>>>lnSuccess=SQLConfigDataSource(0, 1, lcODBCDriver, lcSettings)
>>>>return lnSuccess
>>>>
>>>>This is trying to setup a new DSN with the 32-bit MS ODBC drivers for Oracle
>>>>
>>>>TIA
>>>Mark,
>>>
>>>In the function declaration, does it return a BOOL or a DWORD. If it's a BOOL then 0 does indeed mean that the function failed. However, many functions return 0 (ERROR_SUCCESS) if they're not returning handles, etc.
>>
>>My guess is it is returning Bool -- I go into Win 95 registry and/or ODBC Mgr and the entry does not appear, therefore it has failed to be created.
>>
>>I have done this in the past, and it worked. I am stumped as to where to go from here. I can *manually* add the new DSN via the 32-bit ODBC Manager. But I want to be able to programmatically create the DSN if it does not exist on a user's computer. I have been able to check successfully for the existence (or not) of a DSN.
>
>Without the declaration, it's pretty much of a guess, unless there's an error that a function like GetLastError() would return. Quite possibly it's expecting so of those values to be passed by reference rather than value. That might cause it as well.

I do have to change the driver name to the *description* of the driver ("Microsoft ODBC for Oracle" but it still fails. I found the info on the MSDN Library cd but they fail to give the values of the constants
SQLConfigDataSource

Conformance

Version Introduced:ODBC 1.0

Summary

SQLConfigDataSource adds, modifies, or deletes data sources.

Syntax

BOOL SQLConfigDataSource(
    HWND            hwndParent,
    WORD            fRequest,
    LPCSTR        lpszDriver,
    LPCSTR        lpszAttributes);
Arguments

hwndParent [Input]
Parent window handle. The function will not display any dialog boxes if the handle is null.

fRequest [Input]
Type of request. fRequest must contain one of the following values:

ODBC_ADD_DSN: Add a new user data source.
ODBC_CONFIG_DSN: Configure (modify) an existing user data source.
ODBC_REMOVE_DSN: Remove an existing user data source.
ODBC_ADD_SYS_DSN: Add a new system data source.
ODBC_CONFIG_SYS_DSN: Modify an existing system data source.
ODBC_REMOVE_SYS_DSN: Remove an existing system data source.
ODBC_REMOVE_DEFAULT_DSN: Remove the default data source specification section from the system information. It also removes the default driver specification section from the ODBCINST.INI entry in the system information. (This fRequest performs the same function as the deprecated SQLRemoveDefaultDataSource function.) When this option is specified, all of the other parameters in the call to SQLConfigDataSource should be NULLs; if they are not NULL, they will be ignored.

lpszDriver [Input]
Driver description (usually the name of the associated DBMS) presented to users instead of the physical driver name.

lpszAttributes [Input]
List of attributes in the form of keyword-value pairs. For more information, see ConfigDSN in Chapter 22, “Setup DLL Function Reference.”

Returns

The function returns TRUE if it is successful, FALSE if it fails. If no entry exists in the system information when this function is called, the function returns FALSE.
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform