Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating Access data with Ole automation
Message
From
12/12/2001 11:04:18
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00592774
Message ID:
00593288
Views:
19
This message has been marked as the solution to the initial question of the thread.
>Has anyone created access data via Ole automation?
>
>I have created excel data with Ole but not access.
>
>I would like to open an existing Access database with 3 tables already created,
>polulate the tables with data from an array or cursor, and save the database/tables as another database.
>
>Any insight would be helpful!
>
>Thank you

You can probably do this with OLE automation, but it is easier (IMO) to do it with ADO & ADOX. This simple code would create a new MDB and append a table from an existing MDB:
*-- Open existing access database with ADOX
oCn = Create("ADODB.Connection")
oCatSrc = Create("ADOX.Catalog")

oCn.Open("Provider=Microsoft.Jet.OLEDB.3.51;Data Source=D:\temp\db1.mdb;")
oCatSrc.ActiveConnection = oCn

*-- Create new Access database with ADOX
oCatNew = Create("ADOX.Catalog")
oCatNew.Create("Provider=Microsoft.Jet.OLEDB.3.51;Data Source=D:\temp\newdb.mdb;")

*-- Obtain reference to table in existing MDB
*-- and append it to the new MDB
oTbl = oCatSrc.Tables.Item("myTable")
oCatSrc.ActiveConnection.Close

oCatNew.Tables.Append(oTbl)
oCatNew.ActiveConnection.Close
You can then handle the transferring of the data with ADO. See this white paper at MSDN for detailed info on using ADO and VFP: http://msdn.microsoft.com/library/en-us/dnfoxgen/html/adojump.asp HTH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform