Steps in the example

The following steps show a simple Client-Library application:

  1. Set up the Client-Library programming environment:

    1. Use cs_ctx_alloc to allocate a context structure.

    2. Use cs_config to set any CS-Library properties for the context.

    3. Use ct_init to initialize Client-Library.

    4. Use ct_config to set Client-Library properties for the context.

  2. Define error handling. Most applications use callback routines to handle errors:

    1. Use cs_config(CS_MESSAGE_CB) to install a CS-Library error callback.

    2. Use ct_callback to install a client message callback.

    3. Use ct_callback to install a server message callback.

    WARNING! Applications that do not define error handling do not receive notification of errors that occur in the program, on the network, or on the server. Code your applications to handle errors and server messages. Applications that do not perform error handling are difficult to debug and maintain.

  3. Connect to a server:

    1. Use ct_con_alloc to allocate a connection structure.

    2. Use ct_con_props to set any properties in the connection structure

    3. Use ct_connect to open a connection to a server.

    4. Use ct_options to set any server options for this connection.

  4. Send a language command to the server:

    1. Use ct_cmd_alloc to allocate a command structure.

    2. Use ct_command to initiate a language command.

    3. Use ct_send to send the command.

  5. Process the results of the command:

    1. Use ct_results to set up results for processing (called in a loop).

    2. Use ct_res_info to get information about a result set.

    3. Use ct_describe to get information about a result item.

    4. Use ct_bind to bind a result item to program data space.

    5. Use ct_fetch to fetch result rows (called in a loop).

  6. Finish:

    1. Use ct_cmd_drop to deallocate the command structure.

    2. Use ct_close to close the connection with the server.

    3. Use ct_exit to exit Client-Library.

    4. Use cs_ctx_drop to deallocate the context structure.