version 11 (Modified)
ODBC LOGIN{(dataEntry; userName; password)}
| Parameter | Type | Description | |
| dataEntry | String | Name of the data source entry in the ODBC Manager | |
| userName | String | Name of the user registered in the data source | |
| password | String | Password of the user registered in the data source |
Description
The ODBC LOGIN command allows you to connect to an external ODBC data source or to the 4D internal SQL kernel.
Note: The ODBC (Open DataBaseConnectivity) standard defines a library of standard functions. These functions allow an application like 4D to accesss any ODBC-compatible data source (databases, spreadsheets, etc.) using SQL.
The dataEntry parameter contains the name of the data source as entered in the ODBC driver manager.
To open a connection with the 4D internal SQL kernel, pass the SQL_INTERNAL constant in the dataEntry parameter.
Note: It is not necessary to open a connection using this command if you intend to access the 4D SQL environment using the Begin SQL/End SQL keywords or the QUERY BY SQL command. The connection must be initialized only for the use of other 4D ODBC commands.
userName contains the name of the user authorized to connect to the external data source. For example, with Oracle®, the user name can be "Scott".
password contains the password of the user authorized to connect to the external data source. For example, with Oracle®, the password can be "tiger".
These parameters are optional; if no parameters are passed, the command will bring up the ODBC Login dialog box that allows you to select the external data source:
The scope of this command is per process; in other words, if you want to execute two distinct connections, you must create two processes and execute each connection in each process.
Examples
1. This statement will bring up the ODBC Manager dialog box:
ODBC LOGIN
2. This statement will connect to the ODBC data source named "MyOracle" using Scott/tiger as the name/password :
ODBC LOGIN("MyOracle";"Scott";"tiger")
3. Open a connection with the 4D internal SQL kernel:
ODBC LOGIN(SQL_INTERNAL;$user;$password)
See Also
System Variables or Sets
If the connection is successful, the system variable OK is set to 1; otherwise, it is set to 0.