xsharp.eu • Seek function isn't working for DBF with CDX index in X# - VO Dialect
Page 1 of 1

Seek function isn't working for DBF with CDX index in X# - VO Dialect

Posted: Wed Sep 27, 2023 6:46 am
by ArunBerlin
The below seek is always returning Not Found.
I've manually verified that the sParameter key is present in DBF using a DBF Viewer. Also confirmed that no extra space is present.
Index File used : CDX

Code: Select all

IF INIFILE:Seek(sParameter)
  //Found
ELSE
 //Not Found
ENDIF
Is there any way to solve it ?
Does CDX needs to be reindexed to run in X# and Windows 10 environment.

Re: Seek function isn't working for DBF with CDX index in X# - VO Dialect

Posted: Wed Sep 27, 2023 6:52 am
by Chris
Hi,

Please post the dbf and cdx files (or you can send them directly to me at chris at xsharp eu if they contain sensitive data), together with the exact string you are searching for, so we can have a look and diagnose the problem.

Re: Seek function isn't working for DBF with CDX index in X# - VO Dialect

Posted: Fri Sep 29, 2023 7:01 am
by ArunBerlin
Hi Chris,

I've attached the DBF file and its cdx file with the reply.

Seek : CONNECT STRING
Please have a look at it.

Re: Seek function isn't working for DBF with CDX index in X# - VO Dialect

Posted: Fri Sep 29, 2023 4:15 pm
by Chris
Hi,

Thanks for the files, I see two problems with them:

- The index file seems to be corrupted, when I open it also with VO, I see no records at all. After I rebuild the index, then it works fine. How did you create the index, was it with VO?

- The key expression for the index is USERID+PARAM_CODE, and the field USERIED field contains only the values "BASE", "RAVI", "SLAIRD" and "WELLSK". It's only the PARAM_CODE field that does contain a record with the string you are seeking for ("CONNECT STRING"), so of course simply seeking for this string (without taking into account the first part of the expression) will not give a result, neither in X# or in VO.

Re: Seek function isn't working for DBF with CDX index in X# - VO Dialect

Posted: Thu Oct 05, 2023 11:12 am
by ArunBerlin
Hi,

Thank you Chris, for giving the insight. The .cdx file was picked from an older system having VO environment.

Could you please provide a brief description on how to rebuild index in Windows 10 X# ?

Yes, the seek() also had a logical error.

Re: Seek function isn't working for DBF with CDX index in X# - VO Dialect

Posted: Thu Oct 05, 2023 11:45 am
by Chris
Hi Arun,

The easiest way is to just delete the .cdx file and recreate it with this small code:

FUNCTION Start() AS INT STRICT
LOCAL cDbf AS STRING
cDbf := "C:\.....\INIFILE"
DbUseArea(,"DBFCDX",cDbf)
? DbCreateIndex(cDbf, "USERID+PARAM_CODE")
DbCloseArea()
RETURN 0