Configuring a Data Source

An ODBC Data Source to access a Zim database can be configured in two different ways:

. Using the Zim ODBC Driver Setup to create a data source;

. Using Zim language to dynamically create and maintain a data source tailored for specific needs like calling a third party software from within Zim.

In both cases, the Zim ODBC Driver product must have been previously installed in the machine where the setup or the dynamic configuration is going to happen.

Zim ODBC Driver Setup

The setup of the desired Data Source will happen via the Zim ODBC Driver setup dialog invoked this way (this procedure was based on Windows XP environments; other Windows environments might be slightly different):

. Press the Start button on windows;

. Select Control Panel;

. Select Administrative Tools;

. Select Data Sources (ODBC);

. On the ODBC Data Source Administrator window, either click on the User DSN or System DSN tab. The User DSN indicates that the new data source will be accessible by the current user of this Windows environment, whereas the System DSN indicates that the new data source can be used by all users of this machine provided that they have the appropriate permission. Unless internal policies used in your company state otherwise, click on the System DSN tab;

. Next, click on the "Add..." button the start the new setup (if you already have an existing Data Source that needs to be changed, click on the button "Configure...");

. The Zim ODBC Driver Setup appears with the following aspect:

where the fields mean:

Data Source

Provides a unique name that identifies this Data Source. It can be any text to describe this particular set of connect parameters.

DB Name

The database name used to connect to Zim Server.

User ID

Assigns the user name under which you wish to log in to the Zim database. This User ID must be known by the Zim database.

Password

Assigns the password for "User ID".

Host

The name or IP address of the machine where the target Zim Server is running.

Port Number

The number of the port on which the Zim Server is listening.

Dynamic Creation of a Data Source

Zim language can be used to dynamically create and maintain a data source belonging to the System DSN group of data sources.

The following Zim statements create a new Data Source called "MyDataSource":

let v = $setproperty("REG:[ODBC]", "MyDataSource", $getproperty("REG:[ODBC]", "VERSION"))
let v = $setproperty("REG:[ODBC]", "MyDataSource\\DBQ", "Example")
let v = $setproperty("REG:[ODBC]", "MyDataSource\\Driver", $getproperty("REG:[ODBC]", "DRIVER"))
let v = $setproperty("REG:[ODBC]", "MyDataSource\\DSN_NAME", "MyDataSource")
let v = $setproperty("REG:[ODBC]", "MyDataSource\\Host", "localhost")
let v = $setproperty("REG:[ODBC]", "MyDataSource\\Server", "6002")
let v = $setproperty("REG:[ODBC]", "MyDataSource\\UID", "ZIM")
let v = $setproperty("REG:[ODBC]", "MyDataSource\\WorkPath", $workpath)

After these Zim commands have been executed, any third party software that connects to a Zim database in order to retrieve or update data, can make use of the ODBC Data Source "MyDataSource" via a Zim SYSTEM command:

SYSTEM "C:\\MySoftware\\MyExecutable.exe MyDataSource" CLOSE

The properties "VERSION" and "DRIVER" cannot be set because the are established at installation time by the Zim ODBC Driver Installer.

A third party software can invoke a Data Source created this way and use per user entity sets. Refer to the section Using Per User Entity Sets for further details.

The same way data source properties can be set, they can also be retrieved using the Zim command $SetProperty as shown in these examples:

out $getproperty("REG:[ODBC]", "MyDataSource\\DBQ")                              % Prints the name of the database
out $setproperty("REG:[ODBC]", "MyDataSource\\Host")                              % Prints the address of the host