Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- C# Open DBF file
- public override bool OpenFile(string fileName, string subFileName = "")
- {
- OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(fileName) + ";Extended Properties=dBASE IV;User ID=;Password=;");
- try
- {
- if (con.State == ConnectionState.Closed) { con.Open(); }
- OleDbDataAdapter da = new OleDbDataAdapter("select * from " + Path.GetFileName(fileName), con);
- DataSet ds = new DataSet();
- da.Fill(ds);
- con.Close();
- int i = ds.Tables[0].Rows.Count;
- return true;
- }
- catch
- {
- return false;
- }
- }
- da.Fill(ds);
- "Provider=VFPOLEDB.1;Data Source=" + FullPathToDatabase
- OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:folder;Extended Properties=dBASE IV;User ID=;Password=;"); // give your path directly
- try
- {
- con.Open();
- OleDbDataAdapter da = new OleDbDataAdapter("select * from tblCustomers.DBF", con); // update this query with your table name
- DataSet ds = new DataSet();
- da.Fill(ds);
- con.Close();
- int i = ds.Tables[0].Rows.Count;
- return true;
- }
- catch(Exception e)
- {
- var error = e.ToString();
- // check error details
- return false;
- }
Add Comment
Please, Sign In to add comment