MQL5 ReferenceWorking with databasesDatabaseColumnsCount 


Gets the number of fields in a request.

int  DatabaseColumnsCount(
   int  request      // request handle received in DatabasePrepare



[in]  Request handle received in DatabasePrepare().

Return Value

Number of fields or -1 in case of an error. To get the error code, use GetLastError(), the possible responses are:

  • ERR_DATABASE_INVALID_HANDLE (5121) - invalid request handle.


There is no need to call the DatabaseRead() function to get the number of fields of a request created in DatabasePrepare(). For the remaining DatabaseColumnXXX() functions, DatabaseRead() should be preliminarily called.

See also

DatabasePrepare, DatabaseFinalize, DatabaseClose