4

We need to read data from FoxPro 8 with C#. I'm gonna do some operations, and will push some of thoses data to an SQL Server database. We are not sure what's best method to read those data.

I saw OLE DB and ODBC; what's best?

REQUIRMENTS:

  1. The export program will run each night, but my company runs 24h a day.
  2. The DBF could sometimes be huge.
  3. We DON'T need to modify data.
  4. Our system, wich use FoxPro, is quite unstable: I need to find a way that ABSOLUTELY do not corrupt data, and, ideally, do not lock DBF files while reading.
  5. Speed is a minor requirement: it must be quick, but requirement #4 is most important.
Kendrick
  • 3,747
  • 1
  • 23
  • 41
Bestter
  • 877
  • 1
  • 12
  • 29

4 Answers4

5

I would use the OLEDB connector - it has been updated much more recently, is faster and handles memory better.

If you are just reading data from the DBF via the OLEDB driver, I wouldn't worry about locking at record or file level, or corrupting data. All you need to do is handle exceptions in your C# code, for example when some process in your FoxPro application has the DBF open exclusively and you can't read it.

You also need to be careful that any queries are optimised to use available indexes on the DBF file, especially since you mention that it's large.

I assume this is all on the same LAN? If it has to work across the internet then you need to investigate exposing the FoxPro data via a web service.

Finally, there are other options for accessing DBF files.

Sybase also provide ODBC and OLEDB drivers that can access DBF files - however they cannot use FoxPro triggers, stored procedures and so on. That almost certainly doesn't matter in your case, though.

Alan B
  • 4,086
  • 24
  • 33
2

According to this MSDN article, it suggests using the Visual FoxPro OLE DB Provider. Look at the article and it gives examples on how to to use the OLE DB provider and how to query data from the DBF data source.

Icemanind
  • 47,519
  • 50
  • 171
  • 296
0

It's also quite easy to write some code in VFP that will dump the data to CSV or XML - consider adding this code to your FoxPro application. Processing these files could be much easier than trying to connect to a flaky FoxPro database.

William Mioch
  • 917
  • 9
  • 21
  • Ok. After that, I need another tool to import it to SQL Server? I don't think that the most performant way... – Bestter Oct 02 '12 at 14:58
  • It's not meant to be performant - it's the simplest and least likely to corrupt your data, which you listed as more important than speed. As for importing it into SQL Server, google has 3.5 Million results. – William Mioch Oct 03 '12 at 04:03
  • I understand. If the other agency is not able to use OLE DB, or have problem using it, I will suggest this idea. They are doing test like right now! Thank you – Bestter Oct 04 '12 at 13:04
0

There is a LinqToVfp tool on Codeplex. See: http://linqtovfp.codeplex.com

It has some nice samples that will help get you started.

MattSlay
  • 9,115
  • 5
  • 43
  • 52