Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Use append from while record copying folder to folder
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Use append from while record copying folder to folder
Divers
Thread ID:
01105083
Message ID:
01105083
Vues:
52
Hi All,
i've a small problem about use ... then append from

how ?
below codes copy current records from current data folder to the new structured data folder...
but there is a small problem . if there is a new table(s) on the new structure folder normally error occurs about
... not opened table ..... etc.

how to modify my codes for this error ?

TIA
Set Escape Off
Set Deleted On
Set Safety Off
Set Date To Dmy
Set Century On

If Empty(Thisform.txtfrom.Value) Or Empty(Thisform.txtto.Value)
	Messagebox('Source and Target Folders not Selected..',16,'Opppps')
	Return
Endif

If ! File(Addbs(Thisform.txtfrom.Value)+'data1.dbc')
	Messagebox('Source Folder doesnt contain valid database (data1.dbc)',16,'Hata...')
	Return
Endif

If ! File(Addbs(Thisform.txtto.Value)+'data1.dbc')
	Messagebox('Target Folder doesnt contain valid database (data1.dbc)',16,'Hata...')
	Return
Endif

Local LcFrom,Lcto,OldPath,FirstLcFrom1,FirstLcFrom,FirstLcTo

OldPath = Sys(5)+Curdir()
FirstLcFrom = Alltrim(Thisform.txtfrom.Value)
FirstLcFrom1 = Justfname(Alltrim(Thisform.txtfrom.Value))
FirstLcTo = Alltrim(Thisform.txtto.Value)
LcFrom = Addbs(Thisform.txtfrom.Value)
Lcto = Addbs(Thisform.txtto.Value)

Close Databases All

*--- first backup current database -----------------------------------------------------
Local LcSourcePath,LcTargetPath

LcSourcePath=Alltrim(Thisform.txtfrom.Value) 
LcTargetPath='UPDYDK_' + Substr(Dtoc(Date()),1,2) + Substr(Dtoc(Date()),4,2) + Substr(Dtoc(Date()),7,4)+"_" + ;
	SUBSTR(Tran(Time()),1,2)+Substr(Tran(Time()),4,2)+Substr(Tran(Time()),7,2)

Wait Window "Current Data Folder being backup before update...." Nowait
oFSO=Createobject("Scripting.FileSystemObject")
oFSO.CopyFolder("&LcSourcePath","&LcTargetPath",.T.)  
Messagebox("Backup Succesful....Backup Folder: "+ m.LcTargetPath,64,_Screen.Caption)

*----- renaming current data dir -------------------------------------------------------
Local LcRenameTo
LcRenameTo = 'DB_' + Substr(Dtoc(Date()),1,2) + Substr(Dtoc(Date()),4,2) + Substr(Dtoc(Date()),7,4)+"_" + ;
	SUBSTR(Tran(Time()),1,2)+Substr(Tran(Time()),4,2)+Substr(Tran(Time()),7,2)

fso = Createobject("Scripting.FileSystemObject")
oFolder = fso.GetFolder(m.LcFrom)  &&rename folder
oFolder.Name = m.LcRenameTo
Messagebox("Current Database Folder "+ m.LcRenameTo + " Has been renamed...",64,_Screen.Caption)

*----- renaming new data structure data dir to current dir name ------------------------
fso1 = Createobject("Scripting.FileSystemObject")
oFolder1 = fso1.GetFolder(m.Lcto)  &&rename folder
oFolder1.Name = m.FirstLcFrom1 
Messagebox("New Struture Folder name " + m.FirstLcTo + " Dizini " + m.FirstLcFrom + " has been renamed...",64,_Screen.Caption)
*---------------------------------------------------------------------------------------

Set Path To Data &&update for myaudit

Local LcOldDir,LcNewDir,LcTable
LcOldDir = m.OldPath + m.LcRenameTo + "\"  &&ADDBS("...")
LcNewDir = m.OldPath + m.FirstLcFrom1 + "\"  &&ADDBS("...")

*Wait Window LcOldDir
*Wait Window LcNewDir

Local lcupdatelog
lcupdatelog = Sys(5)+Curdir()+"updatelog.txt"

Set Textmerge To (m.lcupdatelog) Noshow
Set Textmerge On

\UPDATED TABLE LIST

For i=1 To Adir(laTableList, m.LcNewDir + "*.dbf")
	LcTable = laTableList[i,1]
	\<<m.lctable>>
	Wait Window " Old " + m.LcTable +" Records Transferring To The New " + m.LcTable Nowait
	Use (m.LcNewDir + m.LcTable) Exclusive
	Append From (m.LcOldDir + m.LcTable)
	Use
Endfor

Set Textmerge Off
Set Textmerge To

Messagebox("Old Records Has Been Moved To New DataSet...You Can See Table List at..." + ;
	m.lcupdatelog,64,'Data Updater Result')

Close All
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform