OleDb Excel: no value for one or more required parameters

I am trying to extract some data from an excel file, the problem is I was reading the first line as data, so I decided to change the HDR in my connectionString to Yes, but after that my program ends up with the exception given in the topic title.

Here is my code and my request:


 DataTable dt = Utils.queryXlsFile(Qry, dbConnection);


QueryXlsFile method:

public static DataTable queryXlsFile(String query, OleDbConnection dbConnection)
    OleDbDataAdapter dbCommand = new OleDbDataAdapter(query, dbConnection);
    DataTable dt = new DataTable();
    return dt;


And my request:

select top 10 * FROM [PERSONNE$] WHERE (((([F1] LIKE '% prénom %') OR ([F1] LIKE '% prénom')) OR ([F1] LIKE '%-prénom')))


My connection string seems to be good as I can open a file connection.

Thanks in advance for your help.


source to share

1 answer

If you have HDR = No, the column names will be automatically generated as F1, F2, ...

If you have HDR = Yes, the column names will be taken from the header row of your table.

You need to replace "F1" in your request with the field name from the header line.



All Articles