Contents > CFML Reference > ColdFusion Java CFX Reference > Query interface > getData PreviousNext

getData

Retrieves a data element from a row and column of a query. Row and column indexes begin with 1. You can find the number of rows in a query by calling getRowCount. You can find the number of columns in a query by calling getColumns.

Returns the value of the requested data element.

Query interface

public String getData(int iRow, int iCol)

IndexOutOfBoundsException If an invalid index is passed to the method.

setData, addRow

Parameter

Description

iRow

Row to retrieve data from (1-based)

iCol

Column to retrieve data from (1-based)

The following example iterates over the rows of a query and writes the data back to the user in a simple, space-delimited format:

int iRow, iCol ;
int nNumCols = query.getColumns().length ;
int nNumRows = query.getRowCount() ;
for ( iRow = 1; iRow <= nNumRows; iRow++ )
{
   for ( iCol = 1; iCol <= nNumCols; iCol++ )
   {
      response.write( query.getData( iRow, iCol ) + " " ) ;
   }
   response.write( "<BR>" ) ;
} 

Contents > CFML Reference > ColdFusion Java CFX Reference > Query interface > getData PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.