Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting Records out of Access Tables
Message
De
02/11/2004 17:24:08
Gaylen Miller
Leaderware Corporation
Fulton, Illinois, États-Unis
 
 
À
28/10/2004 13:50:50
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
00954660
Message ID:
00957375
Vues:
20
Hi James,

As it turns out Automation is not the best way of extracting tables from Microsoft Access.

Here is the code I ended up with:
lcImportFromDir = "C:\TEST_MDB\"
lcExportToDir = "C:\TEST_DBF\"

lcOpenMDB = (SYS(2000,(lcImportFromDir + ("*.mdb"))))
DO WHILE ! EMPTY(lcOpenMDB )
	lcExportTableName = LEFTC(lcOpenMDB,(AT(".",lcOpenMDB)-1))
	lnConnHandle = SQLSTRINGCONNECT('DSN=MS Access Database;DBQ=' + lcImportFromDir + lcOpenMDB + '; DefaultDir=' + lcImportFromDir + ';DriverId=25;FIL=MS Access; MaxBufferSize=2048; PageTimeout=5; UID=admin;')
	SQLTABLES(lnConnHandle, ['TABLE'], 'ThisMDB')
	SELECT ThisMDB
	SCAN
	  lcSQL = 'SELECT * FROM "' + ALLTRIM(table_name) + '"'
	  lcCursor = ALLTRIM(table_name)
	  lcTableName = LEFTC(lcOpenMDB,(AT(".",lcOpenMDB)-1)) + '^' + lcCursor
	  SQLEXEC(lnConnHandle,lcSQL,lcCursor)
	  SELECT (lcCursor)
	  COPY TO (lcExportToDir + lcTableName)
	  USE IN (lcCursor)
	ENDSCAN
	USE IN ThisMDB
	SQLDISCONNECT(lnConnHandle)
	lcOpenMDB = (SYS(2000,(lcImportFromDir + ("*.mdb")),1))
ENDDO
Thanks
Gaylen Miller
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform