4D DSN-less ODBC connection

Took me forever to figure this out because the docs out there for 4D are minimal1 on connecting to the database without a system configured DSN using 4D’s ODBC driver.

Easy configuration of multiple data sources is crucial if you want to use CodeIgniter or any other framework that allows configuration files to control the deployment and connection to various databases.2

// get the connection resource circa 2011 so php ~v5.x 4D's database default port was `19812`
$connect=odbc_connect('DRIVER={4D v11 ODBC Driver};SSL=false;SERVER=192.168.1.100;PORT=19812;UID=user;PWD=password',"","");

I played with various different ways of doing this connection string, and found the above the most straight forward. You can leave password blank if there isn’t one.

Now if only they would make a linux odbc driver…3

DSN Configuration

If I recall correctly our 4D instance was deployed on a Mac Server and PHP a Windows IIS server. So the DSN configuration would’ve had a dialog something like below.

mac odbc admin
Credit: Oracle documentation
windows odbc driver
Credit: Actian documentation

Author’s Note

In hindsight one of my more “popular” 4D/technology posts. 2024-05-27 comments screenshot

Initial md Generated using https://github.com/jsr6720/wordpress-html-scraper-to-md

Original Wordpress categories: [‘4D’]

Original Wordpress tags: “4D”, “4D ODBC driver”, “DSN”

Original Wordpress comments: 7 Comments

Significant revisions

tags: 2011, wordpress, txcowboycoder, 4D, odbc

  • May 27th, 2024 Came in and updated content testing layout. Added original comments
  • May 7th, 2024 Converted to jekyll markdown format and copied to personal site
  • Mar 30th, 2011 Originally published on txcowboycoder wordpress site

EOF/Footnotes

  1. Happy to report documentation is much more comprehensive now https://doc.4d.com/4Dv20/4D/20/Using-a-connection-string.200-6341904.en.html 

  2. Configuration as code all the way back in 2011! 

  3. Nope. 2024 no linux.