How to edit rows in DataTable and update it using SqlCeDataAdapter?
<p>I have been developing some application using Microsoft Server Compact Edition. This is my code:</p>

<pre><code>   public partial class FormAction : Form
    {

        private string dbPath;
        private string connectionString;
        private SqlCeConnection connection;
        private SqlCeDataAdapter adapter;
        private DataTable table;

        public FormAction(String dbPath)
        {
            InitializeComponent();
            this.dbPath = dbPath;
        }

        private void FormAction_Load(object sender, EventArgs e)
        {
            OpenConnection();
            BindDataSouce();
        }

        private void BindDataSouce()
        {
            string sqlSelect = string.Format("Select {0} AS \"{1}\","
                                            + "{2} AS \"{3}\","
                                            + "{4} AS \"{5}\","
                                            + "{6} AS \"{7}\","
                                            + "{8} AS \"{9}\","
                                            + "{10} AS \"{11}\","
                                            + "{12} AS \"{13}\","
                                            + "{14} AS \"{15}\","
                                            + "{16} AS \"{17}\","
                                            + "{18} AS \"{19}\","
                                            + "{20} AS \"{21}\","
                                            + "{22} AS \"{23}\","
                                            + "{24} AS \"{25}\","
                                            + "{26} AS \"{27}\","
                                            + "{28} AS \"{29}\","
                                            + "{30} AS \"{31}\","
                                            + "{32} AS \"{33}\","
                                            + "{34} AS \"{35}\","
                                            + "{36} AS \"{37}\","
                                            + "{38} AS \"{39}\","
                                            + "{40} AS \"{41}\","
                                            + "{42} AS \"{43}\","
                                            + "{44} AS \"{45}\","
                                            + "{46} AS \"{47}\","
                                            + "{48} AS \"{49}\","
                                            + "{50} AS \"{51}\","
                                            + "{52} AS \"{53}\","
                                            + "{54} AS \"{55}\","
                                            + "{56} AS \"{57}\","
                                            + "{59}, {60}, {61}, {62} "
                                            +"FROM {58}",
                                            Constants.NAME, Constants.NAME_ALIAS,
                                            Constants.FACULTY, Constants.FACULTY_ALIAS,
                                            Constants.YEAR, Constants.YEAR_ALIAS,
                                            Constants.GROUP, Constants.GROUP_ALIAS,
                                            Constants.SEX, Constants.SEX_ALIAS,
                                            Constants.NATIONALITY, Constants.NATIONALITY_ALIAS,
                                            Constants.DATE, Constants.DATE_ALIAS,
                                            Constants.WRITING_HAND, Constants.WRITING_HAND_ALIAS,
                                            Constants.THROWING_HAND, Constants.THROWING_HAND_ALIAS,
                                            Constants.CUTTING_HAND, Constants.CUTTING_HAND_ALIAS,
                                            Constants.TAKING_TEETH_BRUSH_HAND, Constants.TAKING_TEETH_BRUSH_HAND_ALIAS,
                                            Constants.TAKING_MATCH_HAND, Constants.TAKING_MATCH_HAND_ALIAS,
                                            Constants.SWEEPING_HAND, Constants.SWEEPING_HAND_ALIAS,
                                            Constants.TAKING_HUMMER_HAND, Constants.TAKING_HUMMER_HAND_ALIAS,
                                            Constants.TAKING_RACKET_HAND, Constants.TAKING_RACKET_HAND_ALIAS,
                                            Constants.TAKING_NEEDLE_HAND, Constants.TAKING_NEEDLE_HAND_ALIAS,
                                            Constants.OPENING_BANK_HAND, Constants.OPENING_BANK_HAND_ALIAS,
                                            Constants.TAKING_SHOVEL_HAND, Constants.TAKING_SHOVEL_HAND_ALIAS,
                                            Constants.DOING_HAIR_HAND, Constants.DOING_HAIR_HAND_ALIAS,
                                            Constants.THROWING_LEG_TO_LEG, Constants.THROWING_LEG_TO_LEG_ALIAS,
                                            Constants.TAKING_STEP_FORWARD_LEG, Constants.TAKING_STEP_FORWARD_LEG_ALIAS,
                                            Constants.JUMPING_LEG, Constants.JUMPING_LEG_ALIAS,
                                            Constants.KICKING_BALL_LEG, Constants.KICKING_BALL_LEG_ALIAS,
                                            Constants.TAKING_WATCH_EAR, Constants.TAKING_WATCH_EAR_ALIAS, 
                                            Constants.MORE_LOUND_SOUND_EAR, Constants.MORE_LOUND_SOUND_EAR_ALIAS,
                                            Constants.TAKING_PHONE_EAR, Constants.TAKING_PHONE_EAR_ALIAS,
                                            Constants.CLOSING_EYE, Constants.CLOSING_EYE_ALIAS,
                                            Constants.TAKING_PENCIL_EYE, Constants.TAKING_PENCIL_EYE_ALIAS,
                                            Constants.TAKING_KALEIDOSCOPE_EYE, Constants.TAKING_KALEIDOSCOPE_EYE_ALIAS,
                                            Constants.TABLE_NAME, Constants.TYPE_OF_HAND, Constants.TYPE_OF_LEG, Constants.TYPE_OF_EAR, Constants.TYPE_OF_EYE);
            SqlCeCommand commandSelect = new SqlCeCommand(sqlSelect, connection);
            adapter = new SqlCeDataAdapter();
            adapter.SelectCommand = commandSelect;
            SqlCeCommandBuilder builder = new SqlCeCommandBuilder(adapter);

            table = new DataTable();
            adapter.Fill(table);

            BindingSource source = new BindingSource();
            source.DataSource = table;
            dataGridViewPersons.DataSource = source;
            //dataGridViewPersons.Columns[29].Visible = false;
            //dataGridViewPersons.Columns[30].Visible = false;
            //dataGridViewPersons.Columns[31].Visible = false;
            //dataGridViewPersons.Columns[32].Visible = false;
        }

        private void OpenConnection()
        {
            connectionString = string.Format("DataSource=\"{0}\"; Password=\"{1}\"", dbPath, Constants.DB_PASSWORD);
            connection = new SqlCeConnection(connectionString);
            connection.Open();
        }

        private void FormAction_FormClosed(object sender, FormClosedEventArgs e)
        {
            connection.Close();
        }

        private void toolStripMenuItemSaveChanges_Click(object sender, EventArgs e)
        {   
            try
            {
                dataGridViewPersons.BindingContext[table].EndCurrentEdit();
                foreach (DataRow row in table.Rows)
                {

                    row.BeginEdit();
                    row.ItemArray[29] = "A";
                    row.ItemArray[30] = "B";
                    row.ItemArray[31] = "C";
                    row.ItemArray[32] = "D";
                    row.AcceptChanges();
                    row.EndEdit();
                }
                adapter.Update(table);              
            }
            catch (Exception exeption)
            {
                this.Text = exeption.Message;
            }
        }
    }
}
</code></pre>

<p>This code binds data from CE database to DataGridView, and I can add/update/delete any changes in DataGridView and save it without any problems (toolStripMenuItemSaveChanges_Click). But now I need to change some values in columns programatically (setting "A","B","C","D" values), and it doesn't work now (values doesn't be saved). How can I fix it? Thank you in advance. </p>
