#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
时间: 2024-11-09 06:24:42