FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ADO: load recordset into an Array
Posts: 838
Joined: Wed Aug 22, 2007 10:09 AM
ADO: load recordset into an Array
Posted: Sat Nov 16, 2019 02:24 PM
Hi,

In my previous Harbour and FWH version, in order to load contents of Recordset in ADO, I did:

Code (fw): Select all Collapse
  IF ! ( oRsClientes:Eof .and. oRsClientes:Bof )
     oRsClientes:MoveFirst()
     aArray1 := oRsClientes:GetRows()
  ENDIF


But now, the format of the array is wrong. Is there another way to achieve the result?

Thank you.
Saludos / Regards,



FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: ADO: load recordset into an Array
Posted: Sat Nov 16, 2019 06:00 PM
Una idea
Code (fw): Select all Collapse
hData := RsToHash( oRsClientes)
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 838
Joined: Wed Aug 22, 2007 10:09 AM
Re: ADO: load recordset into an Array
Posted: Sat Nov 16, 2019 09:03 PM

Now I have problems with XBROWSE COMMAND:

@ 0, 0 XBROWSE oPanel2:oControl OF oDash ;
COLUMNS 1, 2, 3, 4, 5, 6 ;
HEADERS "Nº Cliente", oSayDNI(), "Apellidos", "Nombre", "Localidad", "Teléfono" ;
ARRAY aArray1 ;
PICTURES "9,999,999"

Does not show the hash.

But the recordset is converted into hash with RsToHash()

Thank you,

Saludos / Regards,



FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ADO: load recordset into an Array
Posted: Sun Nov 17, 2019 04:31 AM
MOISES wrote:Hi,

In my previous Harbour and FWH version, in order to load contents of Recordset in ADO, I did:

Code (fw): Select all Collapse
  IF ! ( oRsClientes:Eof .and. oRsClientes:Bof )
     oRsClientes:MoveFirst()
     aArray1 := oRsClientes:GetRows()
  ENDIF


But now, the format of the array is wrong. Is there another way to achieve the result?

Thank you.


This is due to a change in the Harbour libraries. Nothing to do with FWH.
We have now provided a function
Code (fw): Select all Collapse
aRows := RsGetRows( oRs, [nRows], [nStart], [aFields] )

This function is safe to use with Harbour (both new and old versions) and also xHarbour.
You need to change all
Code (fw): Select all Collapse
aData := oRs:GetRows()

as
Code (fw): Select all Collapse
aData := RsGetRows( oRs )

EVERYWHERE in your application. There is no escape from this, because of the change in Harbour libraries.

Depending on your requirements, you can also use
Code (fw): Select all Collapse
hData := RsToHash( oRs, ..... )
cJson  := RsToJson( oRs, .... )
Regards



G. N. Rao.

Hyderabad, India
Posts: 838
Joined: Wed Aug 22, 2007 10:09 AM
Re: ADO: load recordset into an Array
Posted: Sun Nov 17, 2019 08:17 AM

Thank you. RsGetRows( oRs ) Works perfect.

Two more related questions please:

1.- Is there any other change to ADO stuff that must be aware of?

2.- Also there is the Hash approach: aArray1 := RsToHash( oRs )

Is this fastest?

Saludos / Regards,



FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ADO: load recordset into an Array
Posted: Sun Nov 17, 2019 08:21 AM
2.- Also there is the Hash approach: aArray1 := RsToHash( oRs )

Is this fastest?

RsGetRows() is faster than RsToHash()
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion