# Integration Server Drill-Through Example

    void main(int argc, char *argv[])
    {
    	ESSG_STS_T      sts = ESS_STS_NOERR;
    	ESSG_HGRID_T    hGrid;
    	ESSG_HANDLE_T	Handle;
    	ESSG_INIT_T     InitStruct;

    	/* BEGIN: initialize grid handle and create a new grid */
    	InitStruct.ulVersion      = ESSG_VERSION;
    	InitStruct.ulMaxRows      = 1000;
    	InitStruct.ulMaxColumns   = 200;
    	InitStruct.pfnMessageFunc = ESS_NULL;
    	InitStruct.pUserdata      = ESS_NULL;

    	sts = EssGInit(&InitStruct, Handle);
    	if (sts != ESS_STS_NOERR)
    		return;

    	sts = EssGNewGrid(Handle, hGrid);
    	if (sts != ESS_STS_NOERR)
    		return;
    	/* END: initialize grid handle and create a new grid */

    	ESSG_DTTest(Handle, hGrid);

    	sts = EssGTerm(Handle);
    }

    void ESSG_DTTest(ESSG_HANDLE_T	Handle, ESSG_HGRID_T hGrid)
    {
    	ESSG_STS_T        errsts,
                              sts            = ESS_STS_NOERR;
            ESSG_HLRO_T       hLRO           = 0;
    	ESSG_PPDATA_T	  ppDataIn;
    	/* ESSG_PPDATA_T  ppDataOut; */
    	ESSG_RANGE_T	  rDataRangeIn,
    	                  rDataRangeOut;
    	ESSG_USHORT_T	  usCells;
    	ESSG_USHORT_T	  usState        = 0;
    	ESSG_RANGE_T	  Range;
    	ESSG_PDTHINST_T   pDTInst;
    	ESSG_STR_T        ErrMesg;
    	ESSG_ULONG_T      ErrSize        = 255;
      	memset(&rDataRangeOut, 0, sizeof(ESSG_RANGE_T));
    	ErrMesg = malloc(255);

    	/* connect the grid to a database on the server */
    	sts = EssGConnect(hGrid, server, user, pwd, app, db, ESSG_CONNECT_DEFAULT);

    	if(sts == ESS_STS_NOERR)
    	{
    		ppDataIn = BuildTableForDrillThru (&rDataRangeIn);

    		DisplayOutput(ppDataIn, rDataRangeIn);

    		usCells             = 1;
    		Range.ulRowStart    = 1;
    		Range.ulColumnStart = 6;
    		Range.ulNumRows     = 1;
    		Range.ulNumColumns  = 1;
     		sts = EssGBeginDrillOrLink(hGrid, usCells, &Range, ESSG_OPT_ZOOM);

    	}

    	if(sts == ESS_STS_NOERR)
    		/* send the entire grid to define the query */
    		sts = EssGSendRows(hGrid, &rDataRangeIn, ppDataIn);

    	if(sts == ESS_STS_NOERR)
    	{
    		/* perform the drillorlink operation */
    		sts = EssGPerformOperation(hGrid, 0);

    		/* free the built data */
    		FreeTwoDim(ppDataIn, rDataRangeIn.ulNumRows);
    	}

    	if (sts ==ESS_STS_NOERR)
    		sts = EssGDTRequestDrillThrough(hGrid, usCells, &Range, &pDTInst);

    	if (sts == ESS_STS_NOERR)
    	{
    		/* Get the DT Info corresponding to the DT handle */
    		sts = ESSGDTGetInfo(pDTInst);

    	    /* Set the password info for executing the drill through report */
    		sts = ESSGDTSetInfo(pDTInst);

    		/* determine the list of reports associated with the data cell range. */
    		sts = ESSGDTListReports(pDTInst);

    		/* Execute the report. Using index 0 for now as we have only one report */
    		sts = EssGDTExecuteReport(pDTInst, 0);
    		if ( sts )      /* Error Condition print error mesg */
    			errsts = EssDTAPIGetError(pDTInst, &sts, ErrMesg, ErrSize);

    		/* Get the headers for the report associated with the data cell range. */
    		sts = ESSGDTGetHeader(pDTInst);
    		if ( sts )      /* Error Condition print error mesg */
    			EssDTAPIGetError(pDTInst, &sts, ErrMesg, ErrSize);

    		/* Get the data for the report associated with the data cell range. */
    		sts = ESSGDTGetData(pDTInst);
    		if ( sts )      /* Error Condition print error mesg */
    			EssDTAPIGetError(pDTInst, &sts, ErrMesg, ErrSize);
    	}

    	sts = EssGDTEndDrillThrough(pDTInst);
    }

See the following functions for more information on Integration Server Drill-Through:
EssGDTConnect()
EssGDTEndDrillThrough()
EssGDTExecuteReport()
EssGDTGetData()
EssGDTGetHeader()
EssGDTGetInfo()
EssGDTListReports()
EssGDTRequestDrillThrough()
EssGDTSetInfo()