Connecting to a SQL Anywhere database on Windows CE

In the development environment, the ODBC driver manager provides an interface between the PocketBuilder ODB interface (pkodb20.dll) and the Adaptive Server Anywhere 9 ODBC driver (dbodbc9.dll) or the SQL Anywhere 10 ODBC driver (dbodbc10.dll). The driver manager can handle three types of data source name (DSN) files: system DSNs, user DSNs, and file DSNs. You can create a database connection profile using any of these DSN types.

In applications that you deploy to Windows CE, you must use a file DSN because there is no ODBC driver manager.

Using file DSNs

Windows CE does not provide an ODBC driver manager or an ODBC Administrator. On Windows CE, SQL Anywhere uses ODBC data sources stored in ANSI format files. A file DSN has the same name as the data source, with the extension .dsn, and is usually stored at the root level of the device.

Windows CE also searches for data source files in the following locations:

You can specify either the DSN or the FILEDSN keyword to use file data source definitions in a script. On Windows CE, DSN and FILEDSN are synonyms.

The data source typically specifies the location of the database and the database engine. For more information about defining data sources, see “About SQL Anywhere data sources”.

Using a different SQL Anywhere ODBC driver

The default ODBC driver supplied with Adaptive Server Anywhere version 9 is dbodbc9.dll. You can specify a different ODBC driver by including “driver=dbodbcX.dll” in the ConnectString parameter in the DBParm value or in the file data source, where X is the version number of the SQL Anywhere ODBC driver.

For example, to use a SQL Anywhere 10 ODBC driver on the Windows CE device, you can set the following DBParm value in a script:

SQLCA.DBPARM="ConnectString='DSN=myDSN;driver=dbodbc10.dll;UID=dba;PWD=sql'"
CONNECT using SQLCA;

SQLCA is the default connection object.

If you are running your PocketBuilder applications from the desktop, use the actual name of the driver (for example, “SQL Anywhere 10”) in the ConnectString parameter rather than the name of the DLL. Otherwise, the driver you select in the connection string might be ignored.

For more information about setting SQLCA parameters, see “Assigning values to the Transaction object”.

The DSN you assign must exist in the root directory on the Windows CE device or emulator, or in the \Windows directory or the directory from which the server was started. You can include the driver name in the DSN instead of the DBParm by adding an assignment for the driver in the DSN file:

[ODBC]
enginename=asademo
databasename=asademo
databasefile=\Program Files\Sybase\ASA\asademo.db
start=\Program Files\Sybase\ASA\dbsrv9.exe
Driver=dbodbc9.dll