public int getLastVideoCode() { int lastCode = 0; DaoVideo daoVideo = new DaoVideo(); daoVideo.openConnection(); MySqlDataReader dataReader = daoVideo.executeQuery("SHOW TABLE STATUS LIKE 'VIDEO'"); if (dataReader != null && dataReader.HasRows) { dataReader.Read(); lastCode = dataReader.GetInt16("auto_increment") - 1; } daoVideo.closeConnection(); return lastCode; }
string getCategory(int code) { String res; DaoVideo daoVideo = new DaoVideo(); daoVideo.openConnection(); MySqlDataReader categoryDataReader = daoVideo.executeQuery( "SELECT name FROM CATEGORY WHERE code = " + code); if (categoryDataReader == null || !categoryDataReader.HasRows) return null; categoryDataReader.Read(); res = categoryDataReader.GetString("name"); daoVideo.closeConnection(); return res; }
public List<String> populateTags(int videoCode) { List<String> tags = new List<string>(); String retrieveTagsCommand = "SELECT NAME FROM TAG " + "JOIN VIDEO_TAG on TAG.code = VIDEO_TAG.tagCode " + "WHERE VIDEO_TAG.videoCode = " + videoCode; DaoVideo daoVideo = new DaoVideo(); daoVideo.openConnection(); MySqlDataReader dataReader = daoVideo.executeQuery(retrieveTagsCommand, this.GetType(), "er", "pfff..."); if (dataReader != null && dataReader.HasRows) while (dataReader.Read()) { tags.Add(dataReader["name"].ToString()); } daoVideo.closeConnection(); return tags; }