Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Not a dbf
Message
De
30/01/2009 09:04:39
 
 
À
30/01/2009 08:16:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01378405
Message ID:
01378447
Vues:
50
>Tracy,
>
>we don't have foxfix. Our reparationprocedure works with the stonefield reparation tool :
>error : nested catch message : unable to handle
>error :1
>lineno 19
>message file 'f:\vfp_pjr\meta\*.* does not exist
>linecontent : copy file (locsource) to (locdest)

That error means the file does not exist - it cannot find a file with the wild card *.* You have to point to the exact table with the .dbf extension or let it automatically attempt a repair by opening the file using SDTs OpenTable Method.

Can you post the line of code you used to attempt to open or fix the dbf? Typically it is something like:
*In main.prg:

*Open SDT

PUBLIC oMeta
mydir = "..\DATA" && just an example of where a dbc and meta data tables might exist

oMeta = NEWOBJECT('DBCXMgr', 'DBCXMGR.VCX', '', .F., mydir)

IF  TYPE('oMeta') <> 'O' OR ISNULL(oMeta)
   * display an error message and exit, because
   * DBCX cannot be used

   =Okay('Error Opening the DBC Manager.  App will exit.')

   RETURN
ENDIF

IF !USED('CUSTOMER')
   =UseDbf('CUSTOMER','MyDatabase','CustNo')  && table=Customer, Database = MyDatabase, Order = CustNo
ENDIF
RETURN

***********************************************************************

*In the prg that opens a table:
*the u parameters are passed to this program
*ufile = the filename e.g. mytable.dbf ualias is the alias name to use when opening it

PROCEDURE usedbf
LPARAMETERS ufile, udbc, uorder, ualias, uparm1, uparm2, uparm3, uparm4, uparm5

xreturn = .F.

IF EMPTY(ufile) OR TYPE('ufile') <> "C"
     WAIT WINDOW 'Error in USEDBF.PRG - File name is missing from parameters.  Unable to open table.'
     RETURN xreturn
ENDIF

*Set up your own checks for what is passed, these are just examples

uexclu = .F.              && do not open exclusively
uagain = .F.              && do not add 'AGAIN'
usession = 1	&& use the default datasession
uview  = .F.               && its' a view not a table

IF '.' $ ufile
     ufile = LEFT(ufile,AT('.',ufile)-1)
ENDIF

IF EMPTY(udbc)

     udbc = ''

ELSE

     *---If the udbc contains a '\' assume it is a directory name.  

     IF OCCURS('\', udbc) > 0
          udir = udbc
          IF RIGHT(udir,1) <> '\'
	udir = udir + '\'
          ENDIF
     ENDIF

ENDIF

IF EMPTY(ualias)
     ualias = ''
ENDIF

ON ERROR ErrorHandler(ERROR(), MESSAGE(), LINENO())

*ufile is the .dbf, uorder is the index order, uxeclu is exclusive or not, ualias is the alias, etc...
IF !EMPTY(udir)
     xreturn = oMeta.oSDTMgr.OpenTable(udir+ufile, uorder, uexclu, ualias, .F., usession)
ELSE
     IF !EMPTY(udbc)
          oMeta.SetDatabase(udbc)
     ENDIF
     xreturn = oMeta.oSDTMgr.OpenTable(ufile, uorder, uexclu, ualias, uview, usession)
ENDIF && etc

RETURN xreturn

PROCEDURE ErrorHandler
PARAMETERS tnError, tcMessage, tnLineno

DO CASE
CASE tnError = 1 AND NOT EMPTY(oMeta.oSDTMgr.cAlias)

	*File "<file>" does not exist.

	DO BakUpTbl WITH oMeta.oSDTMgr.cAlias

	oMeta.oSDTMgr.Update(oMeta.oSDTMgr.cAlias)

	RETURN 'Retry'
	
CASE INLIST(tnError, 5, 19, 20, 23, 26, 112, 114, 1124, 1683, 1707, 1567) AND NOT EMPTY(oMeta.oSDTMgr.cAlias)

	* If an index error occurred (5 = record out of range, 19 = index doesn't match
	* DBF, 20 = record not in index, 23 = index expression too big, 26 = table
	* isn't ordered, 112 = invalid key length, 114 = index file doesn't match DBF,
	* 1124 = key too big, 1683 = tag not found, 1707 = structural CDX not found,
	* 1567 = primary key invalid), reindex the table.

	oMeta.oSDTMgr.Reindex(oMeta.oSDTMgr.cAlias)  

	RETURN 'Retry'
etc...
The .repair is usually like this:

oMeta.oSDTMgr.Repair(oMeta.oSDTMgr.cAlias)

after calias is set and the repair is done in the error handler. However, you can call .repair directly but then you have to pass the correct parameters. See the SDT help files for more information.

Another example:
OPEN database MYDatabase  && Database name is MyDatabase in this example
oMeta = NewObject('DBCXMgr', 'DBCXMGR.VCX')
oMeta.SetDatabase(dbc())
IF ! oMeta.oSDTMgr.Repair('CUSTOMER')  && Customer.dbf
    RETURN  && an error 
ENDIF
*Update: Look up Repair in the SDT help file under 'Stonefield Database Toolkit Class Library' It provides good examples on repairing a single table or all tables in a dbc...
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform