Search in DBF file using .idx file

I have a DBF file and an index file. I want to read the index file, and the search entries satisfy some condition. (for example: search entries that its StudentName name begins with "A" using Student.DBF and StudentName.idx)

How to do this programmatically?

0
source share
2 answers

The easiest way would be to request through OleDB Connection

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

}
0
source

, ODBC, ESRI, 3 ( ).DBF(, ), PRJ .SHP. , . Sharpmap codeplex. - dbf ODBC, , . big-endian vs little-endian .

, dbf. , public void ReadAttributes( Stream stream ).

0

Source: https://habr.com/ru/post/1733110/


All Articles