# EssGGetAPIContext

Description

EssGGetAPIContext() gets the Essbase API login context handle for the specified grid.

Syntax

    ESSG_FUNC_M EssGGetAPIContext (hGrid, pEssHctx);

ESSG_HGRID_T | hGrid
ESSG_PPVOID_T | pEssHctx

Parameters

hGrid | Handle passed back from EssGNewGrid.
pEssHctx | Variable for the return of the Essbase API context handle of the connected grid.

Return Value

If successful, returns ESSG_STS_NOERR.

Notes

- Gets the Essbase API login context handle for the specified grid. This allows the caller to call non-Grid Essbase API functions that require an Essbase login context handle.
- If there is no valid connection to the server, there is no valid Essbase API context handle and the call will fail and set *pEssHctx to ESS_INVALID_HCTX.
- Do not use the returned login context in Essbase API functions that would change the context information.

Example

    #include <essapin.h>
    #include <essgapin.h>

    ESSG_FUNC_M     sts = ESS_STS_NOERR;
    ESSG_INIT_T     InitStruct;
    ESSG_HANDLE_T   Handle;
    ESSG_PVOID_T    EssHctx;
    ESSG_HGRID_T    hGrid;

    InitStruct.ulVersion = ESSG_VERSION;
    InitStruct.ulMaxRows = 1000;
    InitStruct.ulMaxColumns = 200;
    InitStruct.pfnMessageFunc = ESS_NULL;
    InitStruct.pUserdata = ESS_NULL;

    /* initializes EGAPI */
    sts = EssGInit(&InitStruct, Handle);

    if(!sts)
       sts = EssGNewGrid(Handle, &hGrid);

    /* connect the grid to a database on the server */
    if(!sts)
       sts = EssGConnect(hGrid, "Rainbow", "Admin",
             "Password", "Demo",
             "Basic", ESSG_CONNECT_DEFAULT);

    /* Get API context handle for the specified grid */
    if(!sts)
       sts = EssGGetAPIContext(hGrid, &EssHctx);
    }

See Also

Using the Grid API Functions
Grid API Structures