日期:2014-05-17 浏览次数:20824 次
string filePath = textBox1.Text; //文件路径,如:E:\a.dbf FileInfo fi = new FileInfo(filePath); string mulu = fi.DirectoryName; string filename = fi.Name; OleDbConnection conn = new OleDbConnection(); string table = filePath; string connStr = @"Provider=VFPOLEDB.1;Data Source=" + mulu + ";Collating Sequence=MACHINE"; conn.ConnectionString = connStr; conn.Open(); string sql = @"select * from " + filename; OleDbDataAdapter da = new OleDbDataAdapter(sql, conn); DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt;