public string InsertNewPlayer(string name, int score) { try { string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Hangman_Scores.sqlite"); var db = new SQLiteConnection(dbPath); var item = new Playerscores(); item.Name = name; item.Score = score; db.Insert(item); return("Record added to the database"); } catch (Exception ex) { return("Error : " + ex.Message); } }
public string DeletePlayer(int id) { try { string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Hangman_Scores.sqlite"); var db = new SQLiteConnection(dbPath); var item = new Playerscores(); item.Id = id; db.Delete(item); return("Record Delete to the database"); } catch (Exception ex) { return("Error : " + ex.Message); } }
public string UpdateScore(int id, string name, int score) { try { string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Hangman_Scores.sqlite"); var db = new SQLiteConnection(dbPath); var item = new Playerscores(); item.Id = id; item.Name = name; item.Score = score; db.Update(item); return("Record Updated"); } catch (Exception ex) { return("Error : " + ex.Message); } }