KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Exploring ODBC connections with 4D
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: June 1, 1998
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Can you connect to a 4D database using ODBC? Yes, you can. 4D ODBC Driver for 4D Server makes your 4D database an ODBC data source and opens it up to the wide world of ODBC on Windows. There are thousands of ODBC-compliant applications running on Windows computers that would love to see what's inside your 4D database. Can you connect to an ODBC data source from 4D and 4D Client? Yes, you can. The 4D ODBC plug-in lets you see any ODBC data source from inside your 4D application. But wait! If 4D ODBC Driver for 4D Server makes your 4D database an ODBC data source, and the 4D ODBC plug-in lets you connect to any ODBC data source from your 4D application, does that mean that you can connect from 4D Client to 4D Server using ODBC? Yes, you can. Here's what you need to get started:
1. 4D Server V6 running on Macintosh or Windows. (Make sure its Database Properties is set to allow 4D Open connections.)
2. 4th Dimension V6 on Windows with a test database. (This could also be another client/server)
3. The ODBC Driver for 4D Server installed and configured on a Windows machine. (See the 4D Driver for 4D Server Reference Manual) To test the connection and see ODBC in action, create and execute a method in your test database such as:

(See the end of this tech tip for the above code for copying to your clipboard)
After running this method, you should get an alert which says "Connected okay..." If not, you'll want to go back and check the setup of your datasource using the ODBC Data Source Administrator application. Of course, a normal 4D Client/Server connection is much faster than an ODBC connection between 4D Client and a 4D Server database. You might want to examine the speed of different ODBC connections. Try connecting to a 4D Server, Oracle, SYBASE and Microsoft SQL Server database. Time it to see how long it takes to connect. You may be as surprised by the results as I was. One last note: Licenses. The ODBC Driver for 4D Server uses 4D Open licenses on the server. (This is why you need the "Database Properties" set to allow 4D Open connections) This means that for each 4D Client license, you can have up to 6 concurrent ODBC (or Open) connections.

Highlight and copy to your clipboard for pasting into 4D

<>ODBC_ID:=OC Login dialog

If(OK=1)

If(<>ODBC_ID>0)
ALERT("Connected okay...")
OC LOGOUT(<>ODBC_ID)
<>ODBC_ID:=0
Else
ALERT("Connection Failed!")
End If
End If