Retrieving data from MySQL with MQL5 simply does not work!

 

I have code like below that runs fine in MQL4. I have put the code in MQL5 with the addition of the ANSI UNICODE transformation.

I have also searched this site and all over the internet for examples retrieving data from MySQL from MQL5.  None found. Doing a complete search of this site

actually return "An error has occurred, try later" 

The code works exactly the same in MQL4 and MQL5 up to the statement:

row = mysql_fetch_row(res_store); 

In MQL4 I get the expected string, in MQL5 I get an empty string. The row is there but I cant get it. 

"Logger" Ouitput:

2011-12-26-15-50 ConnectSQL___ init ok _____ 

2011-12-26-15-50 Initial query: Select TradeID from FSTTrade Where ForexPair = 'AUDUSD' ORDER By SetupDate DESC; 

2011-12-26-15-50 NumRows:_____ 7____________ NumFields:___ 1               <<<<--that is correct

2011-12-26-15-50 row:_________ 

2011-12-26-15-50 row length___ is zero______ 

Number of rows = 7 and number of fields = 1 is correct. 

code:

 string getSTRField(string query2)
  {
   bool queryfail = false;
   string result;
   string row;
   string ansiquery; 
   ansiquery=UNICODE2ANSI(query2);

   int length=StringLen(query2);
  
   int res2 = mysql_real_query(mysql,ansiquery,length);

   if(res2!=0)
    {
     Logger("getSTRField","query result", "mysgl:",IntegerToString(mysql) );
     int mysqlerr=mysql_errno(mysql);
     if (mysqlerr>0)
      {
       Logger( "Returned error: ", ANSI2UNICODE(mysql_error(mysql)) );  

       return(""); 
      }
    }

   int res_store = mysql_store_result(mysql);

   if(res_store==0)
    {
     Logger("getSTRField","GetLastError",DoubleToString(GetLastError(),0));
     return("");
    }
   int numOfRows = mysql_num_rows(res_store);
   int num_fields = mysql_num_fields(res_store);
   
   Logger("NumRows:",IntegerToString(numOfRows),"NumFields:",IntegerToString(num_fields));
 
   row = mysql_fetch_row(res_store);  

  mysql_free_result(res_store);       

   Logger("row:",row);
   if(row==NULL)
    {
      Logger("row is NULL");
      queryfail = true;
    }
   
   if(StringLen(row) == 0)
    {
      Logger("row length","is zero");
      queryfail = true;
    }
   if(queryfail) return "";
  
   row = ANSI2UNICODE(row); 

Reason: