4D v16

Connection to the 4D SQL engine via the ODBC Driver

Home

 
4D v16
Connection to the 4D SQL engine via the ODBC Driver

Connection to the 4D SQL engine via the ODBC Driver  


 

 

You can connect to the 4D SQL Engine from any external database via the ODBC Driver for 4D.

Note: This configuration is used as an example. It is possible to connect 4D applications directly via SQL. For more information, refer to the description of the SQL LOGIN command.

  1. Duplicate the example database that comes with this tutorial
  2. Rename the two folders containing the databases to "Client" and "Server"
  3. Launch the example database inside the Server folder and enable the launching of the SQL Server at startup by checking the "Launch SQL Server at Startup" check-box in the Database Settings, on the SQL page:

  4. Quit and restart the example database from the Server folder to activate the SQL Server.
  5. Install the 4D ODBC Driver for 4D, then check whether it appears in the ODBC Data Source Administrator:
  6. Create a new data source named "Test_ODBC_Driver_v11"


    and test it by pressing the Connection test button:

  7. Launch the example database inside the Client folder, go to the main window and press the "Connect to 4D" button. The code behind this button is the following:


As you can see, in the first part of the method we make a query on the local database. Then, in the second part, we connect to the other 4D database via the ODBC driver and make the same query. The result should be the same of course.

 
PROPERTIES 

Product: 4D
Theme: Tutorial

 
HISTORY 

 
ARTICLE USAGE

4D SQL Reference ( 4D v16)