I am facing 2 issues in OLEDB query
(Problem 1)
I need to get the column names of user uploaded excel sheet. My connection string for excel is
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+fileNameAndPath+";
Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1\"";
Then I will use this command
connection.Open();
DataTable schemaTable = connection.GetSchema("Columns");
Taking column name from each datarow like this
string name = (string)row["COLUMN_NAME"];
It is working fine, if the column name is present in first row of excel. But it will give the column name as "F1,F2,....." if the column name row doesn't start from first row. How can I solve this? is there any way to tell in query, from which row to take the column names?
(Problem 2)
Like the column header I need to select data from a particular range from excel. say like take data from row 3 to row 12. So I used the query like this,
Select RepName, Country from [Sheet1$3:12].
But it is throwing the exception,message like this "No value given for one or more required parameters."
Is any syntax error in my query?
if so can any one please tell how to correct the query?
F1
,F2
instead ofRepname
andCountry
– Pynner