[ Previous ] [ Contents ] [ Index ] [ Next ]

Ns_PdDbClose

Overview

Close a connection to the database.

Syntax

    void  Ns_PdDbClose (void *handle);

Description

This function closes the database. It should not free the database handle. If the close operation is successful, this function should call Ns_PdSendString with OK_STATUS. On failure, the function should use Ns_PdSendString to return an error string.

Psuedo-code Example

    /* Things italicized would be your DBMS-specific structures and 
calls. */
    void
    Ns_PdDbClose(void *handle) {
        DBMSState   *state = (DBMSState *) handle;
        int                 status = NS_OK;
        Ns_PdLog(Trace, "close:");
        if (state->connected) {
            Ns_PdLog(Notice, "Closing database connection: %s", 
    state->datasource);
            if (DBMSClose(state) == DBMSState_ERROR) {
                Ns_PdLog(Error, "Error closing connection:  %s\n", 
state->datasource);
                status = NS_ERROR;
            } else {
                status = NS_OK;
            }
            state->connected = 0;
            if (state->datasource != NULL) {
                free(state->datasource);
            }
            if (state->user != NULL) {
                free(state->user);
            }
            if (state->password != NULL) {
                free(state->password);
            }
            if (state->param != NULL) {
                free(state->param);
            }
            state->connection = NULL;
        } else {
            Ns_PdLog(Notice, "DbClose: not connected.");
        }
        status == NS_OK ? Ns_PdSendString(OK_STATUS) :
        Ns_PdSendException(state->exceptionCode, 
    state->exceptionMsg);
    }

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1998-99 America Online, Inc.