I want to use an OleDbDataAdapter to query an Excel worksheet. I have the OleDbConnection object working fine, and I can connect to the Excel sheet with a simple SELECT statement.
However, all the sheets I want to connect to have the headers on row 4, not on row 1. So I want to SELECT all the rows that have data, starting at row 4.
Something like: "SELECT * FROM [Device$A4:*]";
If i could fugure out how to count the rows in the worksheet, then I could define a range to query .. or maybe there is a better way.
string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data Source=" + file +
";Extended Properties=" + Convert.ToChar(34).ToString() +
"Excel 8.0;HDR=YES" + Convert.ToChar(34).ToString();
string cmdText = "SELECT * FROM [Devices$]";
OleDbConnection connect = new OleDbConnection(connString);
OleDbCommand cmd = new OleDbCommand(cmdText, connect);