I am using an OleDbDataReader to retrieve information from an Excel Spreadsheet. When I attempt to test a column for a null value using the IsDBNull method, I get an error "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
The connection for viewing your linked Microsoft Excel worksheet was lost.".
I cannot see what I am doing wrong, having compared my code to lost of examples. Can anyone advise or help me troubleshoot further
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Uploads\Shelters.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand cmd = new OleDbCommand("Select route from [AA$]", conn);
dr = cmd.ExecuteReader();
if (dr.IsDBNull(0)) //This line produces the error
route = "";
route = dr.GetString(0);