'C# Access Db update query not Updating when data is changed

This is the code i wrote but it's not changing any data in the database even after a successful messageBox

 connection.Open();
            command = new OleDbCommand("UPDATE employeeTable SET fullname=@fullname, [gender]=@gender, [dept]=@dept, [sector]=@sector, [sub_sector]=@sub_sector, [timetable]=@timetable WHERE empid=@empid", connection);



            command.Parameters.AddWithValue("@empid", txtEmpID.Text);
            command.Parameters.AddWithValue("@fullname", txtName.Text);
            command.Parameters.AddWithValue("@gender", cboGender.SelectedItem.ToString());
            command.Parameters.AddWithValue("@dept", cboCompany.SelectedItem.ToString());
            command.Parameters.AddWithValue("@sector", cboSector.SelectedItem.ToString());
            command.Parameters.AddWithValue("@sub_sector", cboSub.SelectedItem.ToString());
            command.Parameters.AddWithValue("@timetable", cboTimetable.SelectedItem.ToString());
            command.ExecuteNonQuery();
            connection.Close();
            MessageBox.Show("Record Updated Successfully!", "NEW EMPLOYEE ADDED", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);


Solution 1:[1]

I didn't get to run your code so you might want to try using

 command.ExecuteScalar();

instead of

command.ExecuteNonQuery();

Also try to avoid direct use of SQL Reserve words for your database table Fields like LEVEL etc so that you avoid SQL Errors.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ngutor Tsenongo