Page 1 of 1

Error in FW_ArrayAsRecordSet Seek - Please help

PostPosted: Sun Aug 06, 2023 5:49 pm
by Cgallegoa
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: Select all  Expand view
#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.

Re: Seek in FW_ArrayAsRecordSet

PostPosted: Sun Aug 06, 2023 6:03 pm
by cnavarro

Re: Error in FW_ArrayAsRecordSet Seek - Please help

PostPosted: Mon Aug 07, 2023 6:42 pm
by Cgallegoa
Mr Rao, Mr Antonio, any idea how to solve the error?

Best regards,

Re: Error in FW_ArrayAsRecordSet Seek - Please help

PostPosted: Tue Aug 08, 2023 6:47 pm
by nageswaragunupudi
Code: Select all  Expand view
? 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.

Re: Error in FW_ArrayAsRecordSet Seek - Please help

PostPosted: Tue Aug 08, 2023 10:34 pm
by Cgallegoa
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: Select all  Expand view
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,

Re: Error in FW_ArrayAsRecordSet Seek - Please help

PostPosted: Wed Aug 09, 2023 7:31 am
by nageswaragunupudi
Except 'index' and 'seek' everything else like Sort, Find, Filter work.
Please tru this small sample
Code: Select all  Expand view
  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.

Re: Error in FW_ArrayAsRecordSet Seek - Please help

PostPosted: Thu Aug 10, 2023 7:31 pm
by Cgallegoa
Mr Rao, I have everything clear. Thank you very much for your kind help.

Best regards,