Retrieving fields values!
test.prg
#include "FWCE.ch"
#define MYSQL_PORT Â 3306
function Main()
  local nRet := MySQL_Connect( "SQL06.FREEMYSQL.NET", MYSQL_PORT, "fivetech", "fivewin" ) // username, password
  local nFields, cFieldName, n, nRow, nField, cFieldValue
 Â
  if nRet == 0
   MsgInfo( "successful connection" )
  Â
   nRet = MySQL_Select_DB( "fwppc" )
   if nRet == 0
     MsgInfo( "database properly selected" )
   else Â
     MsgInfo( MySQL_Get_Last_Error( nRet ) )
   endif Â
  Â
   nRet = MySQL_Execute_Query( "SELECT * FROM customers LIMIT 100" )
   if nRet != 0
     MsgInfo( MySQL_Get_Last_Error( nRet ) )
   else
     MsgInfo( "Number of fields: " + Str( nFields := MySQL_Get_FieldCount() ) ) Â
     for n = 1 to nFields
      MySQL_Get_Field( n, @cFieldName )
      MsgInfo( AllTrim( Str( n ) ) + ": " + cFieldName )
     next Â
     for n = 1 to MySQL_Get_RowCount()
      for nField = 1 to MySQL_Get_FieldCount()
        MySQL_Get_Data( @cFieldValue, nRow, nField )       Â
        MsgInfo( cFieldValue )
      next
     next    Â
   endif
  Â
  else
   MsgInfo( MySQL_Get_Last_Error( nRet ) )
  endif  Â
 Â
  MySQL_Disconnect()
 Â
  MsgInfo( "done!" )
 Â
return nil Â
#pragma BEGINDUMP
// field parameters for mysql_get_field_param() function
#define FIELD_PARAM_CATALOGÂ Â Â Â Â Â Â Â 1
#define FIELD_PARAM_DBÂ Â Â Â Â Â Â Â Â Â 2
#define FIELD_PARAM_TABLEÂ Â Â Â Â Â Â Â Â 3
#define FIELD_PARAM_ORIGTABLEÂ Â Â Â Â Â Â 4
#define FIELD_PARAM_FIELDÂ Â Â Â Â Â Â Â Â 5
#define FIELD_PARAM_ORIGFIELDÂ Â Â Â Â Â Â 6
#define FIELD_PARAM_LENGTHÂ Â Â Â Â Â Â Â 7
#define FIELD_PARAM_TYPEÂ Â Â Â Â Â Â Â Â 8
#define FIELD_PARAM_FLAGSÂ Â Â Â Â Â Â Â Â 9
#define FIELD_PARAM_DECIMALSÂ Â Â Â Â Â 10
int  mysql_connect( char * host, int iPort, char * pszUsername, char * pszPassword );
void mysql_get_last_error( int nErrorCode, char * pszError );
int  mysql_disconnect( void );
int  mysql_select_db( char * pszDatabaseName );
int  mysql_execute_query( char * pszQueryString );
int  mysql_get_fieldcount( void );
int  mysql_get_field( char * char_val, int * int_val, int nParam, int nIndex );
int  mysql_get_rowcount( void );
int  mysql_get_data( char * pszElem, int nRow, int nColumn );
#include <hbapi.h>
HB_FUNC( MYSQL_CONNECT ) // cHost, nPort, cUserName, cPassword
{
  hb_retnl( mysql_connect( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ) ) );
}
HB_FUNC( MYSQL_GET_LAST_ERROR ) // nCode --> cError
{
  char error[ 255 ];
 Â
  mysql_get_last_error( hb_parnl( 1 ), error );
 Â
  hb_retc( error );
} Â Â Â
HB_FUNC( MYSQL_DISCONNECT )
{
  mysql_disconnect();
} Â
HB_FUNC( MYSQL_SELECT_DB ) // cDataBaseName --> nRet
{
  hb_retnl( mysql_select_db( hb_parc( 1 ) ) );
} Â
HB_FUNC( MYSQL_EXECUTE_QUERY ) // cSQLQuery --> nRet
{
  hb_retnl( mysql_execute_query( hb_parc( 1 ) ) );
} Â
HB_FUNC( MYSQL_GET_FIELDCOUNT ) // --> nFields
{
  hb_retnl( mysql_get_fieldcount() );
}
HB_FUNC( MYSQL_GET_FIELD ) // nField, @cName --> nRet
{
  char fieldname[ 255 ];
  int int_buffer;
 Â
  hb_retnl( mysql_get_field( fieldname, &int_buffer, FIELD_PARAM_FIELD, hb_parnl( 1 ) - 1 ) );
  hb_storc( fieldname, 2 );
} Â
HB_FUNC( MYSQL_GET_ROWCOUNT ) // --> nRows
{
  hb_retnl( mysql_get_rowcount() );
} Â
HB_FUNC( MYSQL_GET_DATA ) // @cFieldData, nRow, nField --> nRet
{
  char buffer[ 8192 ]; // max data size = 8K Â
 Â
  hb_retnl( mysql_get_data( buffer, hb_parnl( 2 ) - 1, hb_parnl( 3 ) - 1 ) );
  hb_storc( buffer, 1 );
}
 Â
#pragma ENDDUMP