First add a browser control, TextBox, Button, and a DataGridView control on the form.

Add the following code in Button Click Event
- private void button1_Click_1(object sender, EventArgs e) {
- OpenFileDialog fdlg = new OpenFileDialog();
- fdlg.Title = "Select file";
- fdlg.InitialDirectory = @ "c:\";
- fdlg.FileName = txtFileName.Text;
- fdlg.Filter = "DBF Files(*.dbf)|*.dbf|All Files(*.*)|*.*";
- fdlg.FilterIndex = 1;
- fdlg.RestoreDirectory = true;
- if (fdlg.ShowDialog() == DialogResult.OK) {
- txtFileName.Text = fdlg.FileName;
- Import();
- Application.DoEvents();
- }
- }

You will pass this path in the following function that will return the dbf file data in a dataset.
- public static DataTable GetDataTableDBF(string strFileName) {
- System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection("Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + System.IO.Path.GetFullPath(strFileName).Replace(System.IO.Path.GetFileName(strFileName), "") + ";Exclusive=No");
- conn.Open();
- string strQuery = "SELECT * FROM [" + System.IO.Path.GetFileName(strFileName) + "]";
- System.Data.Odbc.OdbcDataAdapter adapter = new System.Data.Odbc.OdbcDataAdapter(strQuery, conn);
- System.Data.DataSet ds = new System.Data.DataSet();
- adapter.Fill(ds);
- return ds.Tables[0];
- }
You can easily show dataset data in Datagridview.

- DataTable dt = GetDataTableDBF(txtFileName.Text);
- dataGridView1.DataSource = dt.DefaultView;


ajay shindePosted Jun 8, 2018, 9:28 PM EDT
Sir this Code is working fine on Windows 10 32 Bit, but the same does not work on Windows 10 64 Bit, Sir what to do ?
aslam pathanPosted May 25, 2016, 12:56 AM EDT
thanks
lotfi DZPosted Dec 19, 2015, 10:24 PM EST
thanks a lot
chinmaya dashPosted Nov 3, 2015, 11:21 PM EST
try it with oledb it will work
Lau VivienPosted Feb 24, 2014, 5:22 PM EST
Anyone know how to solve ERROR [IM001]?[Microsoft][ODBC Driver Manager] Driver does not support this function?
asghar tayoghPosted Feb 6, 2014, 1:31 AM EST
Tanks Dear Friend
Alex CalidguidPosted Dec 12, 2013, 4:12 AM EST
ERRO[IM002] [Mircosoft][ODBC Driver Manager]Data source name not found and no default driver specified
gautom bosePosted Oct 18, 2013, 12:17 PM EDT
I have Dot Net Framework 4 Client Profile and 4 Client Extended and Dot net Framework 3.5 with sp1
gautom bosePosted Oct 18, 2013, 12:14 PM EDT
I am using windows XP with SP3
gautom bosePosted Oct 18, 2013, 12:14 PM EDT
Problem !! Exception Error message "Error [IM001][Microsoft][ODBC Driver Manager] Driver Does Not Support this Function !
mohammad salmipourPosted Jul 31, 2013, 5:41 AM EDT
Greetings Thanks to the program I want to integrate several databases together The dbf file as a dbf, all of which are Grateful
mohammad salmipourPosted Jul 29, 2013, 7:17 AM EDT
Tanks
vvinnel shadPosted May 19, 2013, 2:28 PM EDT
you the best
Eng Kok HengPosted Jun 9, 2012, 7:22 AM EDT
nice post. Thanks alot.
Eng Kok HengPosted Jun 9, 2012, 7:22 AM EDT
nice pose. Thanks alot.
cyann namPosted Nov 8, 2011, 10:05 PM EST
hello , good job , but i have an error that : "ERROR[IM001][Microsoft][ODBC Drive Manager]Drive does not support this function How to fix this : System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection("Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + System.IO.Path.GetFullPath(strFileName).Replace(System.IO.Path.GetFileName(strFileName), "") + ";Exclusive=No"); Thanks for help !
leo neoPosted Sep 6, 2011, 9:58 PM EDT
vevey good
Quoc Duong VoPosted Apr 21, 2011, 8:03 PM EDT
I'm very happy for this post because it very usefull for me,again, thank you.
Mahesh ChandTOP 10Posted Jul 24, 2010, 6:28 AM EDT
Good info.