Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Export a Table To an Access Database?
Message
From
15/01/2001 12:24:35
 
 
To
15/01/2001 11:59:16
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00463763
Message ID:
00463833
Views:
18
Been waiting for Dave's response about the conditions before posting further (to avoid confusion), but there is a DSN-less way to do it and create a new database besides (Access 2000 with DAO):
#DEFINE DB_TEXT = 10
oAcc=CREATEOBJECT("Access.Application")
oAcc.NewCurrentDatabase("C:\MyData\VFPDATA.MDB")
oMDB=oAcc.CurrentDB
oTbl=oMDB.CreateTableDef("personaldata")
WITH oTbl
   oFld1 = .CreateField("name",DB_TEXT,30)
   oFld2 = .CreateField("address",DB_TEXT,40)
   oFld3 = .CreateField("city",DB_TEXT,20)
   .Fields.Append(oFld1)
   .Fields.Append(oFld2)
   .Fields.Append(oFld3)
ENDWITH
oMDB.TableDefs.Append(oTbl)
oAcc.Quit(0)
RELEASE aAcc
I keep thinking that I might create a "Downsizing Wizard" to automate this (lol).





>There are different ways to do this. The following code uses SQL-passthrough:
>
>*-- build connection string
>lcConnectionStr = "DRIVER={Microsoft Access Driver (*.mdb)};" +;
> "Dbq=c:\temp\bidon.mdb;" +;
> "Uid=Admin;" +;
> "Pwd=;"
>
>*-- connect to MS Access
>lnAccess = SQLSTRINGCONNECT(lcConnectionStr)
>
>*-- create the table
>*-- Note that we need to use Access SQL dialect (char(12) vs. C(12))
>SQLEXEC(lnAccess, "CREATE TABLE test (Type char(12), id char(12))")
>
>*-- select some data
>SELECT type, id FROM HOME()+"foxuser" INTO CURSOR test
>
>*-- insert the result set into MS Access
>WAIT WINDOW NOWAIT "Inserting data into MS Access..."
>SCAN
> SQLEXEC(lnAccess, "INSERT INTO test VALUES('" + Type + "', '"+id+"')")
>ENDSCAN
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform