Solved

Microsoft Visual FoxPro Driver coneect to DBF file

Posted on 2008-10-04
5
1,842 Views
Last Modified: 2012-06-27
I have a song.dbf file, i am able to view using DBF Viewer 2000. My problem is, I am not able to access the dBase table using ADODB connection. I have another try.dbf which i succesfully made connection using ADODB. That file was converted using DBF Viewer 2000, and it only contains 50 records.

song.dbf - Visual dBase 7
try.dbf - FoxBase+/dBase III PLUSE, with memo  

 
Dim SQL As String

dbFileName = "C:\"

Set file1 = CreateObject("ADODB.Connection")

Set record1 = CreateObject("ADODB.Recordset")

constr = "Driver={Microsoft Visual FoxPro Driver}"

constr = constr & ";UID="

constr = constr & ";SourceDB=" & dbFileName

constr = constr & ";SourceType=DBF"

constr = constr & ";Exclusive=No"

constr = constr & ";BackgroundFetch=No"

constr = constr & ";Collate=Machine"

constr = constr & ";Null=Yes"

constr = constr & ";Deleted=Yes"

constr = constr & ";Mode=Read;"

file1.ConnectionString = constr

file1.Open
 

SQL = "SELECT * FROM song"

record1.Open SQL, file1
 

Do While Not record1.EOF

Debug.Print record1("NAME")

record1.MoveNext

Loop

Open in new window

0
Comment
Question by:lohey
  • 3
5 Comments
 

Author Comment

by:lohey
ID: 22639899
I got this error message:
[Microsoft][ODBC Visual FoxPro Driver]Not a table
0
 
LVL 33

Accepted Solution

by:
CarlWarner earned 125 total points
ID: 22642939
Your problem is that a VFP ODBC Driver is not compatible with a Visual dBASE 7 file format.   So, it will end up telling you accurately that your file, song.dbf, is not a table.

You either need a Visual dBASE 7 ODBC driver or you need to convert the song.dbf file with all of its contents to a table format compatible with either the VFP ODBC driver or the OLE DB Provider for VFP.

This reference page shows typical file structures for various versions of the dbf file.  I have no idea how a dbf created with Visual dBASE 7 differs.

Table Header Record Structure
http://msdn.microsoft.com/en-us/library/st4a0s68(VS.80).aspx

See Byte 0 information under the section entitled "Table Header Record Structure".


Both of these support ADO:

Visual FoxPro ODBC Driver
http://msdn.microsoft.com/en-us/vfoxpro/bb190233.aspx

Microsoft OLE DB Provider for Visual FoxPro 9.0 (and earlier)
http://www.microsoft.com/downloads/details.aspx?FamilyId=E1A87D8F-2D58-491F-A0FA-95A3289C5FD4&displaylang=en
0
 

Author Comment

by:lohey
ID: 22643236
Thanks for the reply.
I got all drivers that you mentioned, but still cannot connect to Visual dBase 7 file.
Can provide the connetcton string for Visual dBASE 7 ODBC? Thanks.
0
 
LVL 2

Expert Comment

by:cthulthu
ID: 22651089
Several years ago, we were having problems with making our report writer compatible with dBase 7 (dB7).  I did some investigation and discovered that the header structure of a dB7 file is somewhat different from the norm.  I believe the problem is that the DB7 header allocates 32 bytes for each fieldname whereas the standard Xbase table is smaller.  Thus, standard dBase ODBC drivers will get hung up trying to read the header to find the appropriate information about the table to send back to the application.

Additionally, at bytes 32 - 67, (where other variants of Xbase begin their fieldname subrecords), dB7 reserves space for a language drivername.

I'd recommend looking for a version-specific ODBC driver.  If I find one, I'll post it here.
0
 

Author Comment

by:lohey
ID: 22659498
Alright, thanks for sharing your finding.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Space Delimited Sql File 4 81
ORA-12560: TNS:protocol adapter error 8 80
Unrecognized Database Format 8 89
Exchange 2010 - Best practice MDB Data size 8 40
I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
This article describes some very basic things about SQL Server filegroups.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now