Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
COPY FILE
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00452774
Message ID:
00453916
Views:
18
>I don't know if that van be done, but then the problem i still there. The long field names are stored in the database and not in the table itself.
>What you can do is export to another file type, or create a xml string.
>You can also copy the database with the files. If you for example have four tables that has to be transported, you can place them in a seperate database.
>A third thing you could do, is creating an extra table. In that table you can make a list of the short field names, and the long field names.
>You then can probably create a temporary dbc at the server site. Add the free table that is exported to that database, and then use the extra table to change the field names back to the long names. Now you can simply append from that table.
>
>HTH

Hi Ko,

This is the code from the program called CloneBldMstr. It clones an existing template BldMstr!BldMstr to another location under different names. BldMstr database contains two tables: BldMstr and ValLog. See, if this code can help you.
=OpenTable(lcBldMstrDBF,'WorkFile') && Open Base BldMstr table
select WorkFile
*--- Create a table that holds the structure with validations that we want to create.
ltBldMstr=addbs(gcTempPath)+'b'+sys(2015)
copy structure extended to (ltBldMstr)
use     in WorkFile      && Close bldmstr!bldmstr
* -- PKP: JAN 2000: Since this Vallog is from the BldMstr Master
* -- we don't need the relative name using here.
=OpenTable(lcVallogDBF,'ValLog') && Open Base ValLog table
select Vallog
ltValLog=addbs(gcTempPath)+'v'+sys(2015)
copy structure extended  to (ltValLog)
use     in Vallog     && Close bldmstr!vallog

*--- Create the new database.
if dbused(lcNewBldMstr) && Database is in use, close it first
     lcSetDB=set('database')
     set database to (lcNewBldMstr)
     close database
     if !empty(lcSetDB)
          set database to (lcSetDB)
     endif
endif
local lcOldError, lnError
lcOldError=on('error')
lnError=0
on error lnError=error()
create database (lcNewBldMstr)
on error &lcOldError && Retore previous Error Handler

**** Error cases
if lnError=3 && File is in Use
     =messagebox(lcNewBldMstr+' database could not be created!',48,'Warning')
     select (lnOldArea)
     if lcOldSafety='ON'
          set safety on
     endif
     oJC.CurAppStat='I'
     return .f.
endif

if lnError<>0 && Another problem occurs
     local lnRows
     lnRows=aerror[laErrors]
     =messagebox('Error # '+transform(laErrors[1])+ ;
          ' "'+laErrors[2]+'" occurs...',48,'Warning')
     select (lnOldArea)
     if lcOldSafety='ON'
          set safety on
     endif
     oJC.CurAppStat='I'
     return .f.
endif
***************************************
*--- Update the table_name field value in this extended structure so when added to dbc it has the correct name.
*---- First open extended table in same work space.
=OpenTable(ltBldMstr,'ltBldMstr')
select ltBldMstr
locate
replace table_name with (lcNewBldMstrName+'_B') in ltBldMstr
use     in ltBldMstr     && Close the table

*--- Update the table_name field value in this extended structure so when added to dbc it has the correct name.
*---- First open extended table in same work space.
=OpenTable(ltValLog,'ltValLog')
select ltValLog
locate
replace table_name with (lcNewBldMstrName+'_V') in ltValLog
use     in ltValLog     && Close the table

*--- Create the new table based and add to the dbc.
wait window nowait "Wait while creating "+lcNewBldMstr+'_B'+".DBF ..."  && NSL 4/5/2000 added message
select 0
create (lcNewBldMstr+'_B') database (lcNewBldMstrName) from (ltBldMstr)
flush && To save modifications on the disk

wait window nowait "Wait while creating "+lcNewBldMstr+'_V'+".DBF ..."  && NSL 4/5/2000 added message
select 0
create  (lcNewBldMstr+'_V') database (lcNewBldMstrName) from (ltValLog) && This table would be opened exclusively
*--- Create necessary index(s).
=GenerateIndexes('VALLOG',lcNewBldMstrName+'_V')
flush
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform