Error in FW_ArrayAsRecordSet Seek - Please help

Error in FW_ArrayAsRecordSet Seek - Please help

Postby Cgallegoa » Sun Aug 06, 2023 5: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: Select all  Expand view  RUN
#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.
Last edited by Cgallegoa on Mon Aug 07, 2023 6:45 pm, edited 2 times in total.
Saludos,

Carlos Gallego

*** FWH-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 494
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: Seek in FW_ArrayAsRecordSet

Postby cnavarro » Sun Aug 06, 2023 6: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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Error in FW_ArrayAsRecordSet Seek - Please help

Postby Cgallegoa » Mon Aug 07, 2023 6:42 pm

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

Best regards,
Saludos,

Carlos Gallego

*** FWH-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 494
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: Error in FW_ArrayAsRecordSet Seek - Please help

Postby nageswaragunupudi » Tue Aug 08, 2023 6:47 pm

Code: Select all  Expand view  RUN
? 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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error in FW_ArrayAsRecordSet Seek - Please help

Postby Cgallegoa » 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: Select all  Expand view  RUN
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-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 494
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: Error in FW_ArrayAsRecordSet Seek - Please help

Postby nageswaragunupudi » Wed Aug 09, 2023 7:31 am

Except 'index' and 'seek' everything else like Sort, Find, Filter work.
Please tru this small sample
Code: Select all  Expand view  RUN
  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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error in FW_ArrayAsRecordSet Seek - Please help

Postby Cgallegoa » Thu Aug 10, 2023 7:31 pm

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

Best regards,
Saludos,

Carlos Gallego

*** FWH-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 494
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests