码迷,mamicode.com
首页 > 数据库 > 详细

读取DBF文件数据

时间:2015-08-19 11:03:01      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:

 #region 返回DBF表
        public static System.Data.DataTable getDTFromDBF(string fullPath)
        {
            string pDir = System.IO.Path.GetDirectoryName(fullPath);
            string pFile = System.IO.Path.GetFileNameWithoutExtension(fullPath);
            return getDTFromDBF(pDir, pFile);
        }
        public static System.Data.DataTable getDTFromDBF(string dir, string file)
        {
            string connStr = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + dir + ";Exclusive=No;";
            OdbcConnection conn2 = new OdbcConnection(connStr);
            System.Data.DataTable tableTJ = null;
            try
            {
                conn2.Open();
                string sqlGetTypes = "select * from " + file;
                OdbcDataAdapter daTJ = new OdbcDataAdapter(sqlGetTypes, conn2);
                tableTJ = new System.Data.DataTable();
                daTJ.Fill(tableTJ);
            }
            catch (Exception ex)
            {

            }
            finally
            {
                conn2.Close();
            }
            return tableTJ;
        }
        #endregion

 

 

读取DBF文件数据

标签:

原文地址:http://www.cnblogs.com/cglNet/p/4741274.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!