Error no value given for one or more required parameters.' select from excelsheet

Posted by Ahmedsa under C# on 4/21/2018 | Points: 10 | Views : 1972 | Status : [Member] | Replies : 0
When i try to get data from excel sheet i get error

no value given for one or more required parameters.'

why this happen

i work in visual studio 2010 with excelsheet 2013

my code in c# as following

public DataTable ShowWrongExcelData()


string connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";", txtPath.Text);

OleDbConnection con = new OleDbConnection(connectionString);


string str = @"SELECT [??? ?????????] as [UnitCode],[????? ??????]as[CurrentMeterReading] FROM [Sheet5$] where [CurrentMeterReading] <= 0 ";

OleDbCommand com = new OleDbCommand();

com = new OleDbCommand(str, con);

OleDbDataAdapter oledbda = new OleDbDataAdapter();

oledbda = new OleDbDataAdapter(com);

DataSet ds = new DataSet();

ds = new DataSet();

oledbda.Fill(ds, "[Sheet5$]");


System.Data.DataTable dt = new System.Data.DataTable();

dt = ds.Tables["[Sheet5$]"];

return dt;


why give this error i don't use any parameters

but when i select all data from Excel sheet as following :

@"SELECT [??? ?????????] as [UnitCode],[????? ??????]as[CurrentMeterReading] FROM [Sheet5$]";

I get data without any problem

so that How to solve this error please ?

Excel sheet InvoiceData.xlsx sample


(No response found.)

Login to post response