logo
  • Home
  • My Works
  • Downloads
  • Personal
  • Guest Book
  • About Me

Read the data from foxpro database

Published by Rafeeque B Muhammad on Friday, August 23, 2013 12:00 AM
Updated on Friday, August 23, 2013 12:00 AM


You can use the visual FoxPro oledb provider for connecting the .dbf file. Also it can be downloaded from the below url.

http://www.microsoft.com/en-in/download/details.aspx?id=14839

The below sample application shows how to get the data from the .dbf file. I have created here a sample win form application which helps you to select dbf file and shows the data in the grid.

   private void btnBrowse_Click(object sender, EventArgs e)

        {

            var result = openFileDialog1.ShowDialog();

            txtFileName.Text = openFileDialog1.FileName;

 

            try

            {

                OleDbConnection conn = new OleDbConnection();

                conn.ConnectionString = "Provider=vfpoledb;Data Source=" + txtFileName.Text + ";Collating Sequence=machine;";

                conn.Open();

 

                DataSet ds = new DataSet();

                OleDbCommand cmd = new OleDbCommand("Select * from " + Path.GetFileName(txtFileName.Text), conn);

                OleDbDataAdapter da = new OleDbDataAdapter(cmd);

                da.Fill(ds);

                dataGridView1.DataSource = ds.Tables[0];

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

        }

 

Technical Articles

  • All
  • .NET Framework
  • ASP.NET
  • C#
  • Win Forms
  • WCF
  • SharePoint(WSS 3.0)
  • SQL Server
  • TSQL
  • Oracle
  • PL/SQL
  • Performance and Tuning
  • Application and Tools
  • Outlook programming
  • HTML/HTML5/XHTML/DHTML/JAVAScript/CSS
  • Windows Services
  • Web Services
  • Security
  • Web
  • General
  • Architecture

Technical Books

  • All
  • C# Threading
  • WCF

Other Links

  • Important Links

Techies Craft © 2014 | Privacy Policy