public bool SaveDataGrid() { try { if (connection == null) { return(true); } dataGridView.CurrentCell = null; comandBuilder.RefreshSchema(); dataGridView.EndEdit(); if (adapter.InsertCommand == null) { adapter.InsertCommand = new SQLiteCommand(" "); } if (adapter.UpdateCommand == null) { adapter.UpdateCommand = comandBuilder.GetUpdateCommand(); } if (adapter.DeleteCommand == null) { adapter.DeleteCommand = comandBuilder.GetDeleteCommand(); } adapter.Update(dataSet.Tables[NameTable]); return(true); } catch (Exception e) { MessageBox.Show("Ошибка в процессе сохранения данных.\n" + e.Message, "Ошибка"); return(false); } }