Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting Records out of Access Tables
Message
From
02/11/2004 17:24:08
 
 
To
28/10/2004 13:50:50
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00954660
Message ID:
00957375
Views:
19
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform