FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Error in FW_ArrayAsRecordSet Seek - Please help
Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Error in FW_ArrayAsRecordSet Seek - Please help
Posted: Sun Aug 06, 2023 05:49 PM
Best regards to all.

The FW_ArrayAsRecordSet() function is supposed to return an ADODB.RecordSet type object, an object that includes the Seek() method, which works wonderfully in DB´s MaríaDB, MySql, Postgresql, Sqlite, etc., but, with FW_ArrayAsRecordSet() function, generates error: "ADODB.RecordSet/6 DISP_E_UNKNOWNNAME: PROPERTIES" error
Code (fw): Select all Collapse
#include "FiveWin.ch"

REQUEST DBFCDX

Function Main()
  LOCAL aStruct := {}, aRegs := {}, oRs

  SET EXCLUSIVE OFF
  SET DATE FORMAT TO "dd-mm-yyyy"

  RddSetDefault("DBFCDX")
  dbUseArea(.T.,,"D:\FWH\SAMPLES\CUSTOMER.DBF","Cust")
  dbSetIndex("D:\FWH\SAMPLES\CUSTOMER.CDX")
  OrdSetFocus("Last")

  aStruct := dbStruct()
  aRegs   := FW_DbfToArray()
  oRs     := FW_ArrayAsRecordSet( aRegs, aStruct )
 // xBrowse(oRs, "oRs ArrayAsRecordSet from DBF")
  oRs:Seek( "Simpson" , .T., .F.)   // Genera " Error ADODB.RecordSet/6  DISP_E_UNKNOWNNAME: SEEK"

  dbCloseall()
Return(NIL)
How can it be corrected? I use FWH 20.07, xHarbour and Borland 7.3
A big hug for everyone.

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Seek in FW_ArrayAsRecordSet
Posted: Sun Aug 06, 2023 06:03 PM
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Re: Error in FW_ArrayAsRecordSet Seek - Please help
Posted: Mon Aug 07, 2023 06:42 PM

Mr Rao, Mr Antonio, any idea how to solve the error?

Best regards,

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error in FW_ArrayAsRecordSet Seek - Please help
Posted: Tue Aug 08, 2023 06:47 PM
Code (fw): Select all Collapse
? oRs:Supports( "index" ) // --> .f.
? oRs:Supports( "seek" ) // --> .f.
This is a synthetic recordset and has no server and no physical table and no physical indexes.
So this recordset's CursorLoction property is adUseClient. Even oRs:ActiveConnection is NIL, because this is not connected to any server.

Being a profuse user of indexes and seek, you are aware that a RecordSet supports "index" property and "seek" method only when the recordset opens a physical table as Serverside Cursor using adUseServer and with adCmdTableDirect option and all other kinds of RecordSets do not support Seek method. (Mostly RecordSets are open with adUseClient)

So, this recordset does not support "seek" method.
Instead we need to use Find method.
Regards



G. N. Rao.

Hyderabad, India
Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Re: Error in FW_ArrayAsRecordSet Seek - Please help
Posted: Tue Aug 08, 2023 10:34 PM
Mr. Rao, thank you very much for your reply.

FW_ArrayAs RecordSet also doesn't support the Find method.

Perhaps the only option is to make an ASCAN into the array obtained with RsGetRows( oRs ), and then, position the cursor in the oRS recordset with Rs:AbsolutePosition := nPos.

The code with de option:
Code (fw): Select all Collapse
Function Main()
   LOCAL aStruct := {}, aRegs := {}, oRs

   SET EXCLUSIVE OFF
   SET DATE FORMAT TO "dd-mm-yyyy"

   RddSetDefault("DBFCDX")
   dbUseArea(.T.,,"D:\FWH\SAMPLES\CUSTOMER.DBF","Cust")
   dbSetIndex("D:\FWH\SAMPLES\CUSTOMER.CDX")
   OrdSetFocus("Last")

   aStruct := dbStruct()
   aRegs   := FW_DbfToArray()
   oRs     := FW_ArrayAsRecordSet( aRegs, aStruct )
  // oRs:Seek( "Simpson" , .T., .F.)    // Return "Error ADODB.RecordSet/6  DISP_E_UNKNOWNNAME: SEEK"
  // oRs:Find( "Simpson" )                // Return "Error ADODB.RecordSet/6  DISP_E_UNKNOWNNAME: FIND"

   oRs:Sort := "first,last ASC" // oRs:Fields(0):Name // "INDEX_NAME,ORDINAL_POSITION"
   oRs:MoveFirst()
   aData := RsGetRows( oRs )
   nPos  := ASCAN(aData,{|x| x[2] = "Simpson" })
   oRs:AbsolutePosition := nPos

   xBrowse(oRs)   // Record Found   :) 

   dbCloseall()
Return(NIL)
What do you think ?

Best regards,

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error in FW_ArrayAsRecordSet Seek - Please help
Posted: Wed Aug 09, 2023 07:31 AM
Except 'index' and 'seek' everything else like Sort, Find, Filter work.
Please tru this small sample
Code (fw): Select all Collapse
   USE CUSTOMER
   oRs   := FW_ArrayAsRecordSet( FW_DbfToArray(), DBSTRUCT() )
   xbrowser oRs AUTOSORT
We can sort on any column
We can do incremental seek on the sorted column
We can do incremental wild seek
Also
We can do incremental filters including wild filters.
XBrowse uses Find method for incremental seeks.
Regards



G. N. Rao.

Hyderabad, India
Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Re: Error in FW_ArrayAsRecordSet Seek - Please help
Posted: Thu Aug 10, 2023 07:31 PM

Mr Rao, I have everything clear. Thank you very much for your kind help.

Best regards,

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Continue the discussion