seek char+date

dear all,

i seek stockist code+invoice date but failed to seek. why what i had done...

use invoice shared

index on code+dtoc(inv_date) to invoice.idx

set index to invoice.idx

seek code+dtoc(thisform.txtInvdate.value)

but failed to seek.

thanks.




Answer this question

seek char+date

  • RBrown1375

    thanks for your reply.

    i know there is a code to do so.if i found i will post it to here so as other forummers can take benefits from it.



  • jmw

    CDX is not more easily corruptible than any other index or file-based table.

    As an example I've been using CDX with big tables (over 7 million records+) daily for over 9 years in one VFP app and we did not have corruption once yet.

    As long as your users do not exit abnormally (e.g. shutdown in the middle of posting data), you have a reliable network with quality cabling and quality NICs, UPS installed on workstations, servers and router/hub, as any commercial or corporate network should be, you should not fear corruption.


  • ELM

    hm ic ya thanks for ur advice.

    so do any code to rebuild the cdx

    i guessed must delete tag then reindex the cdx

    thanks in advance.



  • AloneSword

    yes cant seek.

    but i had changed it to dtos(date()) now can seek.



  • WayneTanner

    What do you mean by "failed to seek" Did it error or simply couldn't find a match

    If you mean no match then probably you're switching "set date" in between. Instead use dtoc(,1) which is not affected from set date.


  • Smartguy

    >i know there is a code to do so.if i found i will post it to here so as other forummers can take benefits from it.

    Simply DELETE TAG ALL

    Then INDEX ON field TAG tagname

    Note that DELETE TAG [ALL] will also delete any DB relations you may have.

    You can keep a data dictionary table with all the tables, fields, tags and relations so you can recreate from there, or save yourself all the trouble and get the excellent Stonefield Database Toolkit (SDT) that will do this for you and much more.


  • WebZ

    Yes. Use the INDEX ON command again to rebuild each index tag.

    Do not use the REINDEX command as that could fail if the file header is corrupted.


  • Brian Kuhn

    here is the sample code i get fr www.tek-tips.com

    Databases and tables

    ReBuild your CDX index files
    Posted: 23 Aug 01 (Edited 19 Nov 04)

    *********************************************************
    ** Author Subramanian.G
    ** Function to rebuild CDX index ... this does....
    ** First deletes the index and then recreates them
    ** How to ... =BuildIndex(myDBF)
    ** Last Modified : 19 November, 2004
    *********************************************************
    FUNCTION BuildIndex
    PARAMETERS myDBF

    IF PARAMETERS() # 1
    RETURN .F.
    ENDIF

    LOCAL laIndex, cKey, cIndex

    USE (myDBF)
    DIMENSION laIndex(254,3)

    *** Load the index name and key names in array
    FOR nCount = 1 TO 254
    IF !EMPTY(TAG(nCount)) && Checks for tags in the index
    laIndex(nCount,1) = TAG(nCount) + ' ' && tag name
    laIndex(nCount,2) = KEY(nCount) + ' ' && Key name
    IF PRIMARY(nCount) && Check Index type
    laIndex(nCount,3) = 'P' && Primary Index
    ELSE
    IF CANDIDATE(nCount)
    laIndex(nCount,3) = 'C' && Candidate Index
    ELSE
    laIndex(nCount,3) = 'O' && Other Index types
    ENDIF
    ENDIF
    ELSE
    EXIT && Exit the loop when no more tags are found
    ENDIF
    ENDFOR

    *** Delete the tags
    DELETE TAG ALL

    *** Rebuild Index
    FOR nCount = 1 TO 254
    IF !EMPTY(laIndex(nCount,1))
    cIndex = ALLT(laIndex(nCount,1))
    cKey = ALLT(laIndex(nCount,2))
    IF laIndex(nCount,3) = 'P'
    ** Create Primary key type
    ALTER TABLE (myDBF) ADD PRIMARY KEY &ckey ;
    TAG &cindex
    ELSE
    IF laIndex(nCount,3)='C'
    && Candidate index
    INDEX ON &cKey TAG &cIndex candidate
    ELSE
    INDEX ON &cKey TAG &cIndex
    ENDIF
    ENDIF
    ELSE
    EXIT && Exit the loop when no more tags are found
    ENDIF
    ENDFOR

    USE
    RETURN .T.
    *********************************************************
    ** EOF
    *********************************************************
    ** You can cut & paste and use the above function.
    ** Remember to backup & test this before/after execution.
    ** Accept it at your own risk.



  • Pieter Coetzer - South Africa

    Either you are not getting a match which could be OK or it has to do with date formatting as Cetin suggested.

    In my case, I prefer to use DTOS(Date) as a better choice.
    Also, In VFP is much preferred to use compound indices (CDX) instead of the old IDX format (pre-VFP)

    index on code+dtos(inv_date) tag invoice

    then:

    if seek(StocklistCode+dtos(InvoiceDate))
    * found
    else
    * not found
    endif

  • Kuntal Loya - MSFT

    but cdx more easily corrupted .... dunno i have 3 projects using cdx but so easily corrupted... when i view the tables its a unreadable characters inside the tables. do i have any solutions prevent tis fr happening

    thanks.



  • seek char+date