我有一個DBF文件和一個索引文件。 我想讀取索引文件和搜索記錄滿足一些條件。 (例如:其StudentName以Student.DBF和StudentName.idx開頭的搜索記錄)使用.idx文件在DBF文件中搜索
如何以編程方式執行此操作?
我有一個DBF文件和一個索引文件。 我想讀取索引文件和搜索記錄滿足一些條件。 (例如:其StudentName以Student.DBF和StudentName.idx開頭的搜索記錄)使用.idx文件在DBF文件中搜索
如何以編程方式執行此操作?
這將是最容易通過OLEDB連接查詢
using System.Data.OleDb;
using System.Data;
OleDbConnection oConn = new OleDbConnection("Provider=VFPOLEDB.1;Data Source=C:\\PathToYourDataDirectory");
OleDbCommand oCmd = new OleDbCommand();
oCmd.Connection = oConn;
oCmd.Connection.Open();
oCmd.CommandText = "select * from SomeTable where LEFT(StudentName,1) = 'A'";
// Create an OleDBAdapter to pull data down
// based on the pre-built SQL command and parameters
OleDbDataAdapter oDA = new OleDbDataAdapter(oCmd);
DataTable YourResults
oDA.Fill(YourResults);
oConn.Close();
// then you can scan through the records to get whatever
String EachField = "";
foreach(DataRow oRec in YourResults.Rows)
{
EachField = oRec["StudentName"];
// but now, you have ALL fields in the table record available for you
}
您的意思是,「我如何以編程方式執行此操作?」或者「我如何通過ODBC來做到這一點?」 – 2010-02-02 14:00:16
@Michael:我已經更新了我的問題。謝謝! – 2010-02-02 14:08:12
所以,以編程方式使用ODBC?或不? – 2010-02-02 14:12:34