Solved

How to read a DBF file using VS C#

Posted on 2014-12-19
3
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Making exceptions for ValidationAttribute 2 43
parse string in c# 5 41
Change the color of spectfic dates in date picker control asp.net 29 58
Pdf not loading 2 40
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

738 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