Error in FW_ArrayAsRecordSet Seek - Please help

Post Reply
Cgallegoa
Posts: 497
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador
Has thanked: 1 time
Been thanked: 1 time
Contact:

Error in FW_ArrayAsRecordSet Seek - Please help

Post 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

#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 ***
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: Seek in FW_ArrayAsRecordSet

Post by cnavarro »

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
Cgallegoa
Posts: 497
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Error in FW_ArrayAsRecordSet Seek - Please help

Post by Cgallegoa »

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 ***
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Error in FW_ArrayAsRecordSet Seek - Please help

Post by nageswaragunupudi »

Code: Select all | Expand

? 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
Cgallegoa
Posts: 497
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Error in FW_ArrayAsRecordSet Seek - Please help

Post 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

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 ***
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Error in FW_ArrayAsRecordSet Seek - Please help

Post by nageswaragunupudi »

Except 'index' and 'seek' everything else like Sort, Find, Filter work.
Please tru this small sample

Code: Select all | Expand

   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
Cgallegoa
Posts: 497
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Error in FW_ArrayAsRecordSet Seek - Please help

Post by Cgallegoa »

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 ***
Post Reply