Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Export a Table To an Access Database?
Message
From
22/01/2001 15:27:46
 
 
To
22/01/2001 15:03:42
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00463763
Message ID:
00466937
Views:
32
Sure....use the DBC2MDB utility I uploaded here or use an ODBC connection via a remote view or SQL Passthrough or use an ADO connection or ....

(Near in mind this is not all there is too it, and you have to become familiar with DAO field types .. see the Access online help). Also note the differences in this code between cTbl and oTbl and cMDB and oMDB. One is the name as a character var, the other is an object reference.


#DEFINE adText 10
cTbl="NewTable"
cMDB="C:\Files\NewDatabase.MDB"

oAcc=CREATEOBJECT("Access.Application")
oAcc.NewCurrentDatabase(cMDB) && Makes the new DB
oMDB=oAcc.CurrentDB
oTbl=oMDB.CreateTableDef(cTbl) && Makes the new table

oFld=oTbl.CreateField("Name")
oFld.Type = adText && Could be one of about 18 types...
oFld.Size = 30 && Size only counts for Text (mainly)
oTbl.Fields.Append(oFld) && Append field def to table def

oFld=oTbl.CreateField("Address")
oFld.Type = adText
oFld.Size = 40
oTbl.Fields.Append(oFld)

oFld=oTbl.CreateField("Phone")
oFld.Type = adText
oFld.Size = 20
oTbl.Fields.Append(oFld)

oMDB.TableDefs.Append(oTbl) && Append table def to database definitions

oRS=oMDB.OpenRecordSet(cTbl) && Create an rs managed by Access workspace
oRS.AddNew && Kinda like APPEND BLANK

oRS.Fields("Name").Value = "John Smith"
oRS.Fields("Address").Value = "100 Main Street"
oRS.Fields("Phone").Value = "(850) 555-1212"

oRS.Update
oRS.MoveFirst && Ensures that the RS is updated, kinda like opt. row. buff.
oRS.Close
oAcc.Quit(1)
RELEASE oAcc

>I am trying to create the access DB and add the data to a table within that access database within the foxpro program. Any ideas?
------------------------------------------------
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