Raymart 0 Newbie Poster

I'm new to c# and i'm using vs 2013 and access database..my i need to do multiple update records after I filtered the records in datagridview

in my database table I have these fields ID(PK/autonumber), EID,Date,Day,Daystatus..
In my form I have a button and it's fucntion is filter by date using bidingsource.fiter and this was the result


what I want to happen is when I click another button called "Apply to all" I want to Update all the daystatus to "Legal Holiday" of the filtered records..I know how to update one by one using simple update..but I need to do the multiple update..

I tried to make a code but it was updating all the records not the filtered only here's my code hope someone can help me

OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "SELECT EID From EmployeeTable";
command.CommandText = query;
String a = "Legal Holiday";
using (OleDbDataReader reader = command.ExecuteReader())
while (reader.Read())

OleDbCommand command2 = new OleDbCommand();
command2.Connection = connection;
//String counter2;
//String status = "Absent";

for (var i = 0; i < 1; i++)
command2.Connection = connection;
string query2 = "update EmployeeData set DayStatus='" + a + "'where EID='" + reader["EID"] + "'";
command2.CommandText = query2;


catch (Exception ex)
MessageBox.Show("error" + ex);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.