I'm having trouble loading Excel data into my application. Can anyone tell me what's wrong with the following method?
My connectionString is:
Code:
private static string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=C:\RD.xls;
Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";";
Code:
private void ReadExcelData()
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
using (OleDbCommand command = new OleDbCommand("SELECT * FROM [Questions$]"))
{
connection.Open();
using (OleDbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine(reader[0].ToString());
}
}
}
}
}