its my first time to access and read an excel file (xlsx) with c#..
i am having problem and the error was: No value given for one or more required parameters
below is my code:
private void button5_Click(object sender, EventArgs e)
{
string ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Class Schedules.xlsx;Extended Properties=""Excel 12.0;HDR=NO;""";
string ExcelQuery;
ExcelQuery = "SELECT A1 FROM [Sheet1$]";
OleDbConnection ExcelConnection = new OleDbConnection(ConnectionString);
ExcelConnection.Open();
OleDbCommand ExcelCommand = new OleDbCommand(ExcelQuery, ExcelConnection);
OleDbDataReader ExcelReader;
ExcelReader = ExcelCommand.ExecuteReader(); //error happens here
while (ExcelReader.Read())
{
MessageBox.Show((ExcelReader.GetValue(0)).ToString());
}
ExcelConnection.Close();
}
since this is my first time, im just trying to read the content of A1, below is my excel file:

but running the code would give me an error: No value given for one or more required parameters.
okay, i found a way to read a specific cell in c#….
location
rCnt=1,cCnt=1isA1in excelbe sure to have:
and add a reference into the project called Microsoft Excel Object Library which can be found under the COM tab…
if you want to read multiple texts, just use for loop
and increment value of rCnt or cCnt…
if you want to write into the cell, i think it could be done this way:
that’s all…hope this will help others