Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open table without cdx file

Status
Not open for further replies.

tseegii

Programmer
Dec 14, 2003
9
0
0
MN
Hello.
i have the 22 table. There is not cdx file in the all tables. How to open and how to append to the another table?
 
My code is:

importpath = GETDIR()
tablenumber = ADIR(imptables, importpath + '*.dbf')

IF RIGHT(importpath,1) = '\'
importpath = LEFT(importpath,LEN(importpath)-1)
ENDIF

CREATE TABLE "&datapath\dataimport.dbf" FREE (prep1 N(10), prep2 N(10), prep3 N(10), prep4 N(10))

SELECT dataimport

FOR nCount = 1 TO tablenumber
APPEND FROM "&importpath\&imptables(nCount,1)"
ENDFOR
/Structural .cdx file is not found/
(OR)
FOR nCount = 1 TO tablenumber
USE "&importpath\&imptables(nCount,1)"
ENDFOR
/Structural .cdx file is not found/
any idea, please

 
Here is a routine that I use when re-indexing

Code:
**************************************************
* FUNCTION: Opens given file after deleting its  *
* structural compound index. Used for reindexing *
**************************************************
PROCEDURE open_noidx
PARAMETERS mcDBFName
PRIVATE mlError

mcCDXName = JUSTFNAME(mcDBFName) + ".CDX"
ERASE (mcCDXName)

ON ERROR mlError = .T.

* --- Attempting To Open Table Will Delete CDX Reference ---
USE (mcDBFName) IN 0
mlError = .F.
ON ERROR DO catcherr

* --- Open It Again Without Internal CDX Reference ---
USE (mcDBFName)
ON ERROR
RETURN !mlError


***********************************************
* FUNCTION: Traps error and sets flag         *
***********************************************
PROCEDURE catcherr
mlError = .T.
WAIT MESSAGE() WINDOW
RETURN

You can change the final ON ERROR line to be whatever you were set to before the call.

Additionally if you pass the entire path with the filename, then you will want to modify the JUSTFNAME line accordingly so that you end up with a fully pathed CDX file name.

With this routine you will end up with the desired table Open in the next available workspace and with NO CDX file. This will allow you to re-create a new index from "scratch".

Good Luck,
JRB-Bldr
 
That's a lot of work to open a table where the cdx has gone missing. I do this a lot with data coming from an outside source.

SET SAFETY OFF will take care of it in one whack.

(I also generally SET CPDIALOG OFF and SET TABLEVALIDATE TO 0)
 
SET SAFETY OFF
SET CPDIALOG OFF
SET TABLEVALIDATE TO 0

Thanks danfreeman, Thanks for all
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top