Hello everyone,
I am using VSTS 2008 + C# + .Net 3.5 to read Excel file created by Excel 2007 (but saved as Excel 2003 xls format). Here is my code, when executing code adapter.Fill(cities), there is exception -- "OldDbException Could not find installable ISAM". Any ideas what is wrong?
static void Main(string[] args)
{
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\data.xls;ExtendedProperties=""Excel 8.0;HDR=YES;""";
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");
DbDataAdapter adapter = factory.CreateDataAdapter();
DbCommand selectCommand = factory.CreateCommand();
selectCommand.CommandText = "SELECT ID FROM [Sheet1$]";
DbConnection connection = factory.CreateConnection();
connection.ConnectionString = connectionString;
selectCommand.Connection = connection;
adapter.SelectCommand = selectCommand;
DataSet cities = new DataSet();
adapter.Fill(cities); // OldDbException Could not find installable ISAM
return;
}
thanks in advance, George