我无法在asp.net中读取.dbf文件。
错误:外部表格不符合预期格式。
1) Using OLEDB
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\VisualFoxproDB;Extended Properties=dBASE 5.0;");
OleDbCommand command = new OleDbCommand("SELECT ID,NAME FROM table.dbf", conn);
conn.Open();
DataTable dt = new DataTable();
dt.Load(command.ExecuteReader());
gv1.DataSource = dt;
gv1.DataBind();
conn.Close();
2. Using ODBC
OdbcConnection conn = new OdbcConnection("Driver={Driver do Microsoft dBase (*.dbf)};DriverId=277;SourceType=DBF;SourceDB=D:\\VisualFoxproDB\\;Exclusive=No");
conn.Open();
string strQuery = "SELECT * FROM D:\\VisualFoxproDB\\test.dbf";
System.Data.Odbc.OdbcDataAdapter adapter = new System.Data.Odbc.OdbcDataAdapter(strQuery, conn);
System.Data.DataSet ds = new System.Data.DataSet();
adapter.Fill(ds);
return ds.Tables[0];