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

EID------Date-----------Day---Daystatus
10175--10/11/2014---sat--------regular
10176--10/11/2014---sat--------regular
10177--10/11/2014---sat--------regular
10178--10/11/2014---sat--------regular

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

try
{
OleDbCommand command = new OleDbCommand();
connection.Open();
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;
command2.ExecuteNonQuery();

}
}
MessageBox.Show("Successfully");



}
connection.Close();
}
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 meeting, networking, learning, and sharing knowledge.