KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Connecting and Disconnecting to a data source using 4D 2004 ODBC Plugins
PRODUCT: 4D ODBC | VERSION: 2004 | PLATFORM: Mac & Win
Published On: September 30, 2004
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

The 4D ODBC Plug-in allows 4D to communicate with data sources accessible by an ODBC driver. 4D 2004 ODBC Plug-ins are low level commands that gives the user the ability to connect to almost every database on the market today. The method below demonstrates how to connect and disconnect from a data source using 4D's 2004 ODBC Plug-in commands.

` Method ODBC_Example
C_LONGINT($Res;$ConnectionID)
C_TEXT($DataSource;$UserName;$Password)
 
$DataSource:="data source name" ` data source name you are trying to connect to
$UserName:="user name" ` user name for the data source
$Password:="password" ` password for the data source
 
` Connect to data source
$Res:=ODBC_SQLAllocConnect ($ConnectionID)
$Res:=ODBC_SQLConnect ($ConnectionID;$DataSource;$UserName;$Password)
 
`Disconnect from data source
$Res:=ODBC_SQLDisconnect ($ConnectionID)