Using Connections

    To use a connection
  1. Call SQLAllocConnect to allocate a connection handle.
  2. Optionally, call SQLSetConnectOption to set connection options or SQLGetConnectOption to get connection options.
  3. Call SQLConnect to use an existing data source to connect to SQL Server.

    Or

    Call SQLDriverConnect to use a connection string to connect to SQL Server.

    A minimum complete SQL Server connection string has one of two forms:

    DSN=dsnname;UID=loginid;PWD=password;

    DRIVER={SQL Server};SERVER=server;UID=loginid;PWD=password;

    If the connection string is not complete, SQLDriverConnect can prompt for the required information.

    Or

    Call SQLBrowseConnect multiple times in an iterative fashion to build the connection string and connect to SQL Server.

  4. Optionally, call SQLGetInfo to get driver attributes and behavior for the SQL Server data source.
  5. Use statements. For more information, see Using Statements.
  6. Call SQLDisconnect to disconnect from SQL Server and make the connection handle available for a new connection.
  7. Call SQLFreeConnect to free the connection handle.