public void AddQuestionToTable(DbQuestion question) { if (isOpen) { string values = question.ToSqlString(); string sql = "insert into question (content, description, type) values (" + values + ")"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); } }
public List <DbQuestion> GetAllQuestions() { List <DbQuestion> questions = new List <DbQuestion>(); if (isOpen) { string sql = "select * from question"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { DbQuestion tempPquestiont = new DbQuestion(); tempPquestiont.Content = reader["content"].ToString(); tempPquestiont.Description = reader["description"].ToString(); tempPquestiont.Type = int.Parse(reader["type"].ToString()); tempPquestiont.Id = int.Parse(reader["id"].ToString()); questions.Add(tempPquestiont); } } return(questions); }