PRODUCT : Borland C++ NUMBER : 1303 VERSION : 1.0 OS : OS/2 DATE : October 25, 1993 PAGE : 1/3 TITLE : Using the Sybase SQL server with Borland C++ OS/2 Using The Sybase SQL Server 1.1 Dynamic Link Library with Borland C++ for OS/2. The Sybase SQL Server database for PC Networks is a dynamic link library that provides a standard C program the ability to access an SQL Database through a set of API function calls. The SQL Server is an executable running on the same or another machine that accepts line-feed ('\n') terminated strings through a named pipe. The SQL Server processes information existing in the database or adds new information. The SQL Database has many advantages over the standard way of database manipulation: The Microsoft SYBASE SQL Server database library 1.1 provides a DLL and an import library to allow 16 bit OS/2 programs to access SQL service through a C program. The DLL consists of 16 bit functions that can be used to register error handling functions, send formatted and unformatted strings to the server, establish connections to the server, and use all the functionality of the SQL server for database operations. Although Microsoft has designed the DLL and import library to work with its 16 bit compiler, the library and DLL can be used with Borland C++ for OS/2 with some limitations. The following document details how to use the 16 bit SQL libraries with Borland C++ for OS/2 2.0(32 bit). This document was written and tested with the 16 bit 1.1 version of Microsoft's Sybase SQL Database Library. With the 16 bit versions of the SQL library/DLL there are 4 issues that need to be addressed to use the DLL from a 32 bit BC++ for OS/2 application. 1) Define all pointers passed to the functions in the SQL library to be __far16. The SQL Database functions must also be defined as __cdecl in addition to the __far16 definition. 2) Define all typedefs and #defines that are using 'int' to be 'short'. In the 16-bit OS/2 an int is 16 bits where in the 32-bit OS/2 an int is 32 bits. The short in 32-bit OS/2 is 16 bits and thus is the same size as a 16-bit OS/2 'int'. PRODUCT : Borland C++ NUMBER : 1303 VERSION : 1.0 OS : OS/2 DATE : October 25, 1993 PAGE : 2/3 TITLE : Using the Sybase SQL server with Borland C++ OS/2 3) When using the 16 bit version of the SQL Database DLL, no functions may be called that require a parameter which is a 16 bit function. Two such functions in the SQL DLL library are dberrhandler() and dbmsghandler(). These function require a single parameter which is 16 bit function. Borland C++ for OS/2 will not generate 16 bit functions to satisfy a 16 bit function parameter to dberrhandler() or dbmsghandler(). A workaround would be to use a 3rd party compiler that generates 16-bit functions and write two extra functions in a DLL. The two functions can then be exported and passed in to the SQL API calls. 4) Any functions from the SQL Library that take a variable number of arguments cannot be called with variable argument lists. The function dbfcmd() cannot be called with variable argument lists. The current version of Borland C++ for OS/2 will not support variable argument lists as parameters to the 16 bit functions. The dbfcmd() function can be called with the two defined variables(the first two variables) but calling the function with any further arguments will cause unpredictable results from the SQL DLL. When attempting to use the function dbfcmd() which takes a variable argument list the following compiler errors may result: 'Multiple declarations for "dbfcmd$32" in module xxx.c' and 'Mutliple declarations for "dbfcmd$16" in modules xxx.c'. The dbfcmd part of the symbol is the actual _far16 variable argument list function being called in the source code. NOTE: The header files for the SQL Database Library are SQLFRONT.H and SQLDB.H are designed for C compilation you will need to enclose the header files in an extern "C" conversion when compiling for C++. Undefined symbols errors will result unless the following encapsulation of the SQL header file is provided: extern "C" { #include #include } DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that PRODUCT : Borland C++ NUMBER : 1303 VERSION : 1.0 OS : OS/2 DATE : October 25, 1993 PAGE : 3/3 TITLE : Using the Sybase SQL server with Borland C++ OS/2 you received with the Borland product to which this information pertains.