Como siempre muchas gracias Cristobal...
Bueno te cuento que cheque la publicación que mencionas, hay varias funciones alli, pero creo que la que mas se adapta a lo que necesito es la función RsToHash( oAdoRs, [nRows], [nStart], [aFields] ) --> Matriz hash
- Code: Select all Expand view
oVar:="SELECT * FROM clientes"
oRsFtr := FW_OPENRECORDSET(oCnFtr,oVar,adLockOptimistic,adOpenKeyset)
hDatos := RsToHash( oRsFtr, 1, 4)
xbrowse(hDatos)
el problema es que al correr la función me sale el siguiente error
- Code: Select all Expand view
Application
===========
Path and name: C:\DLYMA\dlyma.exe (32 bits)
Size: 5,968,896 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613)
FiveWin version: FWH 19.06
C compiler version: Borland/Embarcadero C++ 7.3 (32-bit)
Windows version: 6.2, Build 9200
Time from start: 0 hours 0 mins 7 secs
Error occurred at: 29/07/2019, 17:03:04
Error description: Error ADODB.RecordSet/6 DISP_E_UNKNOWNNAME: GETROWS
Args:
[ 1] = N 1
[ 2] = N 4
Stack Calls
===========
Called from: => TOLEAUTO:GETROWS( 0 )
Called from: .\source\function\ADOFUNCS.PRG => RSGETROWS( 506 )
Called from: .\source\function\ADOFUNCS.PRG => RSTOHASH( 486 )
Called from: c:\dlyma\prg\R32_fact.prg => FPQRS( 58 )
Called from: c:\dlyma\prg\R32_fact.prg => R32_FACT( 39 )
Called from: c:\dlyma\prg\Alyma.prg => (b)TLYMA:AUTORIZA( 1139 )
Called from: c:\dlyma\prg\Alyma.prg => TLYMA:AUTORIZA( 1139 )
Called from: c:\dlyma\prg\R32_menu.prg => (b)MAIN( 440 )
Called from: .\source\classes\TRBTN.PRG => TRBTN:CLICK( 717 )
Called from: .\source\classes\TRBTN.PRG => TRBTN:LBUTTONUP( 917 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1791 )
Called from: .\source\classes\TRBTN.PRG => TRBTN:HANDLEEVENT( 1575 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3546 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 1078 )
Called from: c:\dlyma\prg\R32_menu.prg => MAIN( 529 )
Esta es la función
- Code: Select all Expand view
//----------------------------------------------------------------------------//
function RsToHash( oRs, nRows, nStart, aFields )
return RsGetRows( oRs, nRows, nStart, aFields, "HASH" )
//----------------------------------------------------------------------------//
function RsGetRows( oRs, nRows, nStart, aFields, cFormat )
// cFormat can be "HASH" or "JSON"
local aRows
DEFAULT nRows := -1, nStart := 0
if !Empty( aFields ) .and. HB_ISARRAY( aFields )
aRows := oRs:GetRows( nRows, nStart, aFields )
else
aRows := oRs:GetRows( nRows, nStart ) //LINEA DONDE DEVUELVE EL ERROR
endif
if HarbourNew()
aRows := ArrTransposeQ( aRows )
endif
if HB_ISCHAR( cFormat ) .and. !Empty( cFormat )
cFormat := Upper( Left( cFormat, 1 ) )
if cFormat $ "JH"
if Empty( aFields )
aFields := Array( oRs:Fields:Count() )
AEval( aFields, { |c,i| aFields[ i ] := oRs:Fields( i - 1 ):Name } )
endif
if cFormat == "J"
aRows := ArrToJson( aFields, aRows )
else
aRows := ArrToHash( aFields, aRows )
endif
endif
endif
return aRows