<span style="white-space:pre"> </span>private void Form1_Load(object sender, EventArgs e)
{
string filePath = @"D:\test.dbf";
OdbcConnection conn = new OdbcConnection();
string connStr = @"Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + filePath + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO";
conn.ConnectionString = connStr;
conn.Open();
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = conn;
string sql;
sql = "select * from "+filePath;
OdbcDataAdapter da = new OdbcDataAdapter(sql, conn);
DataTable dt = new DataTable();
da.Fill(dt);
this.dataGridView1.DataSource = dt;
}
C# 操作本地dbf数据库文件
最新推荐文章于 2024-05-17 16:32:30 发布