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 9, 2018, 1:28 AM
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, 4:56 AM
thanks
lotfi DZPosted Dec 20, 2015, 3:24 AM
thanks a lot
chinmaya dashPosted Nov 4, 2015, 4:21 AM
try it with oledb it will work
Lau VivienPosted Feb 24, 2014, 10:22 PM
Anyone know how to solve ERROR [IM001]?[Microsoft][ODBC Driver Manager] Driver does not support this function?
asghar tayoghPosted Feb 6, 2014, 6:31 AM
Tanks Dear Friend
Alex CalidguidPosted Dec 12, 2013, 9:12 AM
ERRO[IM002] [Mircosoft][ODBC Driver Manager]Data source name not found and no default driver specified
gautom bosePosted Oct 18, 2013, 4:17 PM
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, 4:14 PM
I am using windows XP with SP3
gautom bosePosted Oct 18, 2013, 4:14 PM
Problem !! Exception Error message "Error [IM001][Microsoft][ODBC Driver Manager] Driver Does Not Support this Function !
mohammad salmipourPosted Jul 31, 2013, 9:41 AM
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, 11:17 AM
Tanks
vvinnel shadPosted May 19, 2013, 6:28 PM
you the best
Eng Kok HengPosted Jun 9, 2012, 11:22 AM
nice post. Thanks alot.
Eng Kok HengPosted Jun 9, 2012, 11:22 AM
nice pose. Thanks alot.
cyann namPosted Nov 9, 2011, 3:05 AM
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 7, 2011, 1:58 AM
vevey good
Quoc Duong VoPosted Apr 22, 2011, 12:03 AM
I'm very happy for this post because it very usefull for me,again, thank you.
Mahesh ChandPosted Jul 24, 2010, 10:28 AM
Good info.