This is a followup question to the question:
I am attempting to read a Fixed Format Text file using the Microsoft.ACE.OLEDB.12.0 Provider. I have a half dozen different ways to setup the driver and/or provider and pretty much run into the same problem every time. I am for some reason unable to even "get started" because of "Could not find installable ISAM" exceptions or errors and exceptions with the driver.
The system has Office 2007 installed so the "Could not find installable ISAM" does not make a great deal of sense.
Does anyone see the problem with the following code?
string DATABASE_PROVIDER = "Provider=Microsoft.ACE.OLEDB.12.0";
string CVS = Application.StartupPath + @"Data.txt";
string connectionString = DATABASE_PROVIDER = ";Data Source=" + CVS +";Extended Properties=text;HDR=Yes;FMT=Fixed";
string field ="*";
string table ="Data";
string StringQueryCMD = "SELECT" + field+" FROM " + table;
OleDbConnection myConnection = new OleDbConnection( connectionString );
OleDbCommand cmd = myConnection.CreateCommand();
cmd.CommandText = StringQueryCmd;
myConnection.Open(); // <---- "Could not find installable ISAM" exception here
OleDataAdapter myDataAdapter = new OleDbDataAdapter(cmd);
DataTable Table = new DataTable("Data");// <---- "Could not find installable ISAM" exception here
myDataAdapter.Fill(Table);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…