FoxPro to C#: What best method between ODBC, OLE DB or another?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: FoxPro to C#: What best method between ODBC, OLE DB or another?

  1. #1
    Join Date
    Sep 2012
    Location
    Saint-Jean-sur-Richelieu, QC, Canada
    Posts
    1

    FoxPro to C#: What best method between ODBC, OLE DB or another?

    Hi!

    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.


    thank you!

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    10,967

    Re: FoxPro to C#: What best method between ODBC, OLE DB or another?

    You have several options along with those you mentioned:
    Entity Framework 5.0
    SqlConnection/SqlCommand classes

  3. #3
    Join Date
    Jul 2012
    Posts
    90

    Re: FoxPro to C#: What best method between ODBC, OLE DB or another?

    @Arjay - FoxPro is a Jet database, so the classes in the System.Data.SqlClient namespace won't work. He will need to use classes in the System.Data.OleDB or System.Data.Odbc namespaces such as OleDbConnection/OleDbCommand.

    If you have or can obtain a native OleDB provider for FoxPro 8 (I know there is one for FP9) I would suggest OleDB over ODBC. Native connectivity, where available, is always going to be faster and more efficient than going through the ODBC connectivity layer.

    The mdb file, while much better and more stable than the flat files early versions of FP used, are more suceptable to corruption at the file level than SQL Server. No one can guarantee no data corruption, but your FP app is more likely to corrupt the data than your C# export program. As far as locking during reads, that is up to the access locking paradigm used in FP, not your C# code.

    I would suggest...

    Use OleDB if you can, it should be more performant than ODBC.

    Use transactions on the SQL Server side when writing the data, to ensure record level atomicity.

    Use verbose logging to note any record import that has problems and wasn't sucessfully imported (log the actual data, as well as, the reason(s) why there was a problem). This will give you a good basis for fine tuning the process as unforseen data problems are encountered. It may also give you the capability of manually importing problem data once it is fixed.

    Keep your code as simple and streamlined as possible. Depending on the amount and complexity of the import data, these kinds of export/import operations can have long run times (you're really not going to know until you can do a trial run).

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    10,967

    Re: FoxPro to C#: What best method between ODBC, OLE DB or another?

    I believe the OP mentioned that he was going to push some data to SQL server. I was referring this need in my reply.

  5. #5
    Join Date
    Jul 2012
    Posts
    90

    Re: FoxPro to C#: What best method between ODBC, OLE DB or another?

    Point taken Arjay. Since the OP was talking about ODBC and OLD-DB, I was assuming the main thrust of the question was about the best way to connect to and pull data from the FoxPro database.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center