[Solved] Reading A Fixed Format Text File – Part 2


I ended up going with a slightly different solution. The solution to the “Could not find installable ISAM” exception was to use the following:

string EXTENDED_PROPERTIES = @"Extended Properties=""Text;HDR=YES;FMT=FixedLength;""";

The key to the solution is the (s) around the “Extended Properties” values. I was able to populate the DataTable with the contents of the file, I think there was a problem with the ini file, so it contained strings of “—–” which was useless to me.

So I ended up simply reading the access database.

string DATABASE_PROVIDER = "Provider=Microsoft.ACE.OLEDB.12.0";
string CVS Application.StartupPath + ""\\Database.accdb";
string DATA_SOURCE = "Data Source" + CVS;
string connectionString = DATABASE_PROVIDER + DATA_SOURCE;
string TABLE = " FROM STUFF";
string SELECT = "SELECT CODE, NAME, ICON, FUNCTION;
string StringQueryCmd = SELECT + TABLE;

OleDbConnection MyConnection = new OleDbConnection(connectionString);
OleDbCommand Command = OleDbCommand(StringQueryCmd,MyConnection);
OleDbAdapter MyDataAdapter = new OleDbAdapter(Command);
DataSet MyDataSet = new DataSet();
DataTable MyDataTable = new DataTable();
MyConnection.Open();
MyDataAdapter.Fill(MyDataSet,"STUFF");
MyConnection.Close();

Once you have a DataTable you could in theory use LINQ to DataSet instead of dealing with the DataTable.

solved Reading A Fixed Format Text File – Part 2