Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Programming » ODBC support


ODBC connection functions

ODBC supplies a set of connection functions. Which one you use depends on how you expect your application to be deployed and used:

  • SQLConnect   The simplest connection function.

    SQLConnect takes a data source name and optional user ID and password. You may want to use SQLConnect if you hard-code a data source name into your application.

    For more information, see SQLConnect in the Microsoft ODBC API Reference at [external link]

  • SQLDriverConnect   Connects to a data source using a connection string.

    SQLDriverConnect allows the application to use SQL Anywhere-specific connection information that is external to the data source. Also, you can use SQLDriverConnect to request that the SQL Anywhere driver prompt for connection information.

    SQLDriverConnect can also be used to connect without specifying a data source. The SQL Anywhere ODBC driver name is specified instead. The following example connects to a server and database that is already running.

    SQLCHAR     scso[2048];
    SQLDriverConnect( hdbc, NULL,
       "Driver=SQL Anywhere 16;UID=DBA;PWD=sql", SQL_NTS,
       scso, sizeof(scso)-1,
       &cso, SQL_DRIVER_NOPROMPT );

    For more information, see SQLDriverConnect in the Microsoft ODBC API Reference at [external link]

  • SQLBrowseConnect   Connects to a data source using a connection string, like SQLDriverConnect.

    SQLBrowseConnect allows your application to build its own windows to prompt for connection information and to browse for data sources used by a particular driver (in this case the SQL Anywhere driver).

    For more information, see SQLBrowseConnect in the Microsoft ODBC API Reference at [external link]

 See also

Establishing an ODBC connection