Programming Interfaces Guide
CHAPTER 4. ODBC Programming
A sample ODBC program, odbc.c, is supplied in the cxmp subdirectory of the Adaptive Server Anywhere installation directory. The program performs the same actions as the Embedded SQL dynamic cursor example program.
For a description of the associated Embedded SQL program, see Database examples.
Along with the sample program is a batch file, makeall.bat, that can be used to compile the sample program for the various environments and compilers supported by Adaptive Server Anywhere. For OS/2 the command is makeall.cmd. For QNX, use the shell script makeall. The format of the command is as follows:
makeall odbc {Platform} {Compiler}
The first parameter is odbc, meaning compile the ODBC example. The same batch file also compiles the Embedded SQL programs.
The second parameter is the platform in which the program will be run. The platform can be one of:
WINDOWS compile for 16-bit Windows.
WIN32 compile for 32-bit Windows using the Watcom C 32-bit Windows support.
WINNT compile for Windows NT or Windows 95.
OS232 compile for OS/2.
QNX compile for QNX.
The third parameter is the compiler to use to compile the program. The compiler can be one of:
WC use Watcom C or Watcom C/32
MC use Microsoft C
BC use Borland C
CS use IBM C Set++
The example program odbc.c, when compiled for Windows NT, runs optionally as a service.
The two files containing the example code for NT services are the source file ntsvc.c and the header file ntsvc.h. The code allows the linked executable to be run either as a regular executable or as an NT service.
Start Sybase Central and open the Services folder.
Click Add Service. Follow the instructions for adding the sample program as a service.
Right-click the service icon and click Start to start the service.
When run as a service, the program displays the normal user interface if possible. It also writes the output to the Application Event Log. If it is not possible to start the user interface, the program prints one page of data to the Application Event Log and stops.
This example has been tested with the Watcom C/C++ 10.5 compiler and the Microsoft Visual C++ 2.0 compiler.