4D DSN-less ODBC connection
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.
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