Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading MS Acces Files from VFP
Message
From
06/11/2003 06:14:57
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/11/2003 21:34:08
Mike Smith
Doncaster Office Services
Oakville, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00846910
Message ID:
00846980
Views:
34
>I have plowed through a lot of documentation and played around with this and can't get what I want.
>
>I have a MS Access File (.mdb) on the same machine as my VFP application.
>
>I would like to read the MS Access File and use the data from it.
>
>I have gone through The Control Panel and ODBC and created a connection so I can view the .mdb file, but I haven't figured out how to bring the data into .dbf format so I can actually use it.
>
>This has lead me to chapters on SQL, COM, DCOM, ADO and RDO. As I read this stuff it appears to be trying to extract remote data that is sometimes in .dbf format already, so I am not sure which approach I should be using.
>
>Like I would just love it if the was an APPEND FROM command that I could use as for .XLS files.
>
>Before I go far down this trail, I would just like to find out which approach is best for extracting data from a .mdb file when it is on the same machine as the .dbf file. I will then focus my reading in that direction.
>
>Thanks.
>
>Mike Smith

Mike,
Using MDB files are like using SQL server or any other via ODBC, OLEDB. ie:
ldStart = {^1996/08/01}
ldEnd = {^1996/08/31}

lcMDBDir = 'C:\Program Files\Microsoft Office\Office\samples'
lcMDBName = 'NORTHWIND.MDB'
lnConnHandle = SQLSTRINGCONNECT('DSN=MS Access Database;DBQ='+;
  lcMDBDir+'\'+lcMDBName+';DefaultDir='+;
  lcMDBDir+';DriverId=25;FIL=MS Access;MaxBufferSize=2048;'+;
  'PageTimeout=5;UID=admin;')

lcSQL = "select * from [Orders] where [RequiredDate] between ?ldStart and ?ldEnd"

SQLExec(lnConnHandle, lcSQL, 'MyResult') && Get result into cursor myResult
SQLDisconnect(lnConnHandle)
Select myResult
Browse
lcSQL in sample could be any SQL command, not just only select-SQL.
myResult cursor could be made updatable with little effort if you ever want to edit and send back the data.
You can use it as any other VFP cursor (almost - some commands are not allowed like adding/modifying columns with alter table). ie: You could append from this cursor (or insert into) into another.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform