public bool UpdateWordInDb(GrammarWord grammarWord) { bool result = true; using (SQLiteCommand sQLiteCommand = connection.CreateCommand()) { try { sQLiteCommand.CommandText = "UPDATE GrammarWords SET Name=@name, PRONUNCIATION_COUNTER=@pronunciationCounter WHERE Id=@id"; sQLiteCommand.Parameters.AddWithValue("@id", grammarWord.Id); sQLiteCommand.Parameters.AddWithValue("@name", grammarWord.Name); sQLiteCommand.Parameters.AddWithValue("@pronunciationCounter", grammarWord.Counter); sQLiteCommand.ExecuteNonQuery(); } catch (SQLiteException ex) { result = false; MessageBox.Show(ex.Message); } } return(result); }
public bool InsertWordToDb(GrammarWord grammarWord) { bool result = true; using (SQLiteCommand sQLiteCommand = connection.CreateCommand()) { try { sQLiteCommand.CommandText = "INSERT INTO GrammarWords (Name, PRONUNCIATION_COUNTER) VALUES (@name,@pronunciationCounter)"; sQLiteCommand.Parameters.AddWithValue("@name", grammarWord.Name); sQLiteCommand.Parameters.AddWithValue("@pronunciationCounter", grammarWord.Counter); sQLiteCommand.ExecuteNonQuery(); } catch (SQLiteException ex) { result = false; MessageBox.Show(ex.Message); } } return(result); }