Page 1 of 1

FW_DbfSqlQuery does not work

Posted: Fri Jun 19, 2020 3:08 pm
by damianodec
Hi,
I'm trying this code:

Code: Select all

#include "fivewin.ch"
#include "xbrowse.ch"
#include "hbcompat.ch"

function Main()

   local nAvgAge, aData, cSql
   local cFolder  := "c:\fwh\samples\"

   TEXT INTO cSql
   SELECT A.STATE AS CODE,S.NAME AS STATENAME,A.NUM,A.AVGAGE,A.SALARY FROM
   (  SELECT STATE, COUNT(*) AS NUM, AVG(AGE) AS AVGAGE, SUM(SALARY) AS SALARY
      FROM CUSTOMER GROUP BY STATE ) A
   LEFT OUTER JOIN STATES S ON A.STATE = S.CODE
   ENDTEXT

   aData    := FW_DbfSqlQuery( cFolder, cSql )
   nAvgAge  := FW_DbfSqlQuery( cFolder, "SELECT AVG(AGE) FROM CUSTOMER" )
   // nAvgAge := nAvgAge[1,1] // for FWH13.06 and earlier

   XBROWSER aData TITLE "Statewise Employees" ;
      SETUP (  oBrw:cHeaders := { "Code", "StateName", "NumEmp", "AvgAge", "TotalSalary" }, ;
               oBrw:cEditPictures := { nil, nil, "999", "99.99", "99,999,999" }, ;
               oBrw:lFooter  := .t., ;
               oBrw:NumEmp:nFooterType := oBrw:TotalSalary:nFooterType := AGGR_SUM, ;
               oBrw:AvgAge:bFooter := { || nAvgAge }, ;
               oBrw:Code:cFooter := cValToChar( Len( aData ) ), ;
               oBrw:MakeTotals() )

return nil
but does not works.

I checked inside dbffunc2.prg (FW_DbfSqlQuery Function) and at this row crashed

Code: Select all

...
oCn := FW_OpenAdoConnection( cFolder)
...
 
any suggestion ?

Thank you.

Re: FW_DbfSqlQuery does not work

Posted: Mon Jun 22, 2020 6:05 pm
by nageswaragunupudi
This sample code is working for me as expected, include nAvgSalary.
Please check if the folder "c:\fwh\samples\" really exists on your computer.
Note: This may not work with 64-bit applications.