Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to read a DBF file using VS C#

Posted on 2014-12-19
3
Medium Priority
?
539 Views
Last Modified: 2014-12-24
I have this code that establishes a connection to a series of dbf files. My question now is how to point it to any one particular file, open that file and proceed to read the records? My ultimate goal here is to parse each record and then via a SQL connection transfer the data from dbase to SQL.

       private OdbcConnection GetDBFConnection()
       {
           /* Create reader and open file containing connection string */
           TextReader tr = new StreamReader(@"DBF.INI");

           /* Read line containing the connection string */
           DBFConnectionString = tr.ReadLine();

           /* Close the stream */
           tr.Close();

           try
           {
               DBFDataConnection = new System.Data.Odbc.OdbcConnection(DBFConnectionString);
               DBFDataConnection.Open();
           }
           catch (Exception ex)
           {
               string eMsg = "Error-Opening SQL connection: " + ex.Message;
               if (StackTraceWanted) eMsg += "\n" + ex.StackTrace;
               MessageBox.Show(eMsg);
           }

           return DBFDataConnection;
       }
0
Comment
Question by:rwheeler23
  • 2
3 Comments
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 40509223
Hi rwheeler23;

Have you given any thought of using the application configuration file to store your connection strings in. If you use the application config file you can give each connection string a name and be able to retrieve it from the file by that name. Have a look at this web post for info.

Connection Strings and Configuration Files
0
 

Author Comment

by:rwheeler23
ID: 40510161
I found a Dbase reader that can read these types of dbf file. I can use their export tool to dump out to csv or Excel. I do not understand why my connect string did not allow this. These are the file types this program can read.

•dBASE PLUS
•Personal dBASE
•dB2K
•Visual dBASE 7.5
0
 

Author Closing Comment

by:rwheeler23
ID: 40517023
I do not understand these files. However I was able to find an export tool and that is all I need for now.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month7 days, 17 hours left to enroll

824 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