TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed elbarbary
NA
1.6k
277.8k
error no value given for one or more required parameters.'
Apr 21 2018 4:40 AM
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);
con.Open();
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$]"
);
con.Close();
System.Data.DataTable dt =
new
System.Data.DataTable();
dt = ds.Tables[
"[Sheet5$]"
];
return
dt;
}
why give this error i dont 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 anyh problem
so that How to solve this error please ?
Excel sheet InvoiceData.xlsx sample
http://www.mediafire.com/file/b62b5ub26mrt9t1/InvoiceData.xlsx
Reply
Answers (
3
)
IN VS 2008 CONVERT JSON TO STRING IN C#
how to add data for particular cell in listview