• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 838
  • Last Modified:

VS C# dbf files

I have a collection of dbf files that I wanted to import into SQL. Using the import task in SQL every time I I point to any of these files, I am able to see the table names but when I zero in on any one file I get the message that file is not of the correct type. ("External table is not in the expected format"). I have tried downloading dbf file tools and they all come back with similar messages. I am wondering that perhaps whatever is creating these files is doing something with the file headers to make them invalid. My thought right now it to create a VS C# application in which I will then parse each record and extract out what I need. What should I use in the connection string for these files that will allow me to parse each character and determine where one field ends and the next begins as well as the end of record? Would it be better to specify a dbf type file? Is there a connection string parameter that can be used to specify that? How do I read dbf files using VS C#?
0
rwheeler23
Asked:
rwheeler23
  • 4
  • 3
  • 2
2 Solutions
 
James ShinevarCommented:
What is the source of these dbf files?  Are they from FoxPro?  What version of SQL Server are you looking to import them to?  Is it 32 or 64 bit?  Sorry to drop a lot of questions, I'm actually in the middle of a FoxPro to SQL Server conversion right now.
0
 
rwheeler23Author Commented:
We are using SQL 2012. I have been given these dbf's that are generated by a third party product with no support. I threw every dbf reader I could find and none of them could read them. The ISV product can read them. That is why I know want to write a VS C# program just so I go character by character to see what is in the file. I did find one file called Dbase Runtime Edition.
0
 
James ShinevarCommented:
hmmm... so they are probably dbase files then.  I hate to plug a solution that requires a purchase, but this is what I ran into: we had FoxPro dbf files and SQL Server 2014 x64.  There is no "driver" or direct solution to migrate FoxPro to SQL Server 2014 x64.  If I had a SQL Server 2005 32bit server, my FoxPro drivers would have allowed me to make an ODBC connection and import the tables.  Since I didn't have that as an option, I used a solution from DBConvert https://dbconvert.com/download.php .   I downloaded the trial and when I saw it could convert within the limitations of the trial program (meaning not all the rows), I purchased the solution.  Perhaps one of their solutions will work for you.  It's worth a try, even while looking for a free alternative.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
James ShinevarCommented:
I have also read that it may be possible to import the dbf to Access and then import your access database to SQL Server, that might be a way to try.
0
 
rwheeler23Author Commented:
That is true, but I need to automate the transfer as it will be occurring daily. My first desire would have been to create an SSIS package but that is off the table now.
0
 
GEOFSCommented:
Can you open the DBF's in Excel?
0
 
rwheeler23Author Commented:
No. I get the same message. External file is not of the correct format. I did find something called Dbase 9. This is the only file I found that could read these files.
0
 
GEOFSCommented:
Going back to your original plan to build a program to parse the file, the DBF header record contains, among other things, the names, types, lengths, etc. of the fields in the table.  The structure of the header record is fully described in the VFP documentation.
0
 
rwheeler23Author Commented:
I will use an export tool that is able to read these files. Thanks for your help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now