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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export simultaneously to sdf

Status
Not open for further replies.

ewqdascxz

IS-IT--Management
Aug 4, 2011
23
PH
In VFP, can i export tables simultaneously to a .sdf file type without browsing the table? If i will open a .dbc file containing at least 100 tables, can i simultaneously export them to .sdf?
 
I'm not sure what you mean by "simultaneously".

You can certainly export one or more tables to SDF without browsing it:

Code:
USE MyTable
COPY TO SomeFile.txt SDF

To copy 100 tables in a DBC, you could do this:

Code:
* Get tables names into an array
OPEN DATABASE MyDatabase
lnCount = ADBOBJECTS(laTables, "TABLE")

* Loop through the array
FOR lnI = 1 TO lnCount
  USE (laTables(lnI)) 

  * Make the output filename the same as the table's,
  * but with TXT instead of DBF
  lcFile = FORCEEXT(laTables(lnI))

  * Copy the table to SDF
  COPY TO (lcFile) SDF
ENDFOR

I haven't tested this, so can't be sure it's completely correct, but it should give you the general idea.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
See ABDOBJECTS(), it'll give you a list of tables of a DBC, ADIR() also can give you a list of tables in a directory. Then you can loop all array rows and use and export all tables.

What do you want to achive? Migrating dbfs to another database? SDF files may not be the best option. You could export data into the detination database via at least 3 techniologies VFP offers: SQL passthrough, remote views and cursoradapters.

Bye, Olaf.
 
Mike, you forgot to specify the next TXT fileextension. Your code otherwise is fine, but would actually write out files without extension. You're halfway fortunate, that ADBOBJECTS() does not return dbf file names, but just the table names :).

You wanted to do
lcFile = FORCEEXT(laTables(lnI),"txt")

Bye, Olaf.
 
what i mean is it possible to export those 100 tables all together(not one table at a time) to a .sdf file type? and thanks for the reply
 
How would that differ? Do you think Mutlitasking/processind will make this faster? Or do you want to append all into one sdf file?

Bye, Olaf.
 
I'm trying to migrate my files from VFP to magic edeveloper which supports .sdf file type.
 
Ok, the code Mike gave does export ALL tables of the database in a loop. One by one, but without user interventions, depending on how much data you have in your tables you'll not notice that it's done one by one...

This is how computers do stuff seemingly simultaniously, they do it one after the other command, but faaaast. ;)

Bye, Olaf.
 
but there's a problem.. nesting error? what could be the problem? thanks again
 
nesting error? what could be the problem? thanks again
 
Have you ammended the FORCEEXT() as I said? And have you copied the code fully, including the ENDFOR? The only loop in the code (also called nested code) is between FOR and ENDFOR, and a nesting error is reported, if the end of the nested code does not exist, that's also true, if you forgot a ENDIF or ENDDO or ENDSCAN or any such loop/secrtion ending command.

Hav you embedded mikes code somewhere? If so, can you post the full code you try to execute?

Bye, Olaf.


 
oh! Yeah, I forgot about that. But where will those files will be export to?
 
Well, whereever you want. Just add a CD command eg. C:\my\folder to let VFP create files there.

Bye, Olaf.
 
You're also facing one problem: Foxpo does not export Memo fields, General Fields, Blob and other fields stored in FPT files. This brings me back to my initial suggestion to not go through SDF.

Bye, Olaf.
 
where will I add the CD command? Yeah, thanks for the suggestion but through SDF is my only option
 
and there's also another problem. LNI is not found. I really appreciate your help OlafDoschke and also to MikeLewis.
 
my bad again, I already found the cause of the error
 
LNI? Is it a table name and the table is missing?

CD command: Well, at the beginning, before you write out files.
Directly after the OPEN DATABASE command would be a nice place for CD into another directory.

Bye, Olaf.
 
Will I use "COPY to" to set a specific location?
 
The error about LNI? was it about the counter variable of the FOR loop? Did you type out the code instead of copying it? You know you can copy code, you don't need to retype it.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top