1. 程式人生 > >c#讀取dbf檔案並輸出某一列

c#讀取dbf檔案並輸出某一列

 private void button1_Click(object sender, EventArgs e)
        {
            string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\work\\test\\python\\extractopoints;Extended Properties=dBASE IV;User ID=Admin;Password=;";
            string fileName = "E:\\work\\test\\python\\extractopoints\\1.dbf"
; OleDbConnection con = new OleDbConnection(constr); var sql = "select * from " + fileName; OleDbCommand cmd = new OleDbCommand(sql, con); con.Open(); DataSet ds = new DataSet(); ; OleDbDataAdapter da = new OleDbDataAdapter(cmd); da.Fill(ds); foreach
(DataRow theRow in ds.Tables[0].Rows) { Console.WriteLine(theRow["ID"]); } Console.WriteLine("success"); }