Esempio n. 1
0
        public static List <TalkerFile> GetFiles(string section)
        {
            List <TalkerFile> talkerFiles = new List <TalkerFile>();

            using (MySqlConnection conn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString)) {
                using (MySqlCommand cmd = new MySqlCommand("SELECT fileId, fileName, contents, section, description FROM talkerFiles WHERE section = ?section ORDER BY fileName", conn)) {
                    cmd.Parameters.AddWithValue("section", section);

                    cmd.Connection.Open();

                    MySqlDataReader dataReader = cmd.ExecuteReader();
                    TalkerFile      currentTalker;

                    while (dataReader.Read())
                    {
                        currentTalker = new TalkerFile();

                        currentTalker.FileId      = long.Parse(dataReader["fileId"].ToString());
                        currentTalker.FileName    = dataReader["fileName"].ToString();
                        currentTalker.Contents    = dataReader["contents"].ToString();
                        currentTalker.Section     = dataReader["section"].ToString();
                        currentTalker.Description = dataReader["description"].ToString();

                        talkerFiles.Add(currentTalker);
                    }

                    cmd.Connection.Close();
                }
            }

            return(talkerFiles);
        }
Esempio n. 2
0
        public static List<TalkerFile> GetFiles(string section)
        {
            List<TalkerFile> talkerFiles = new List<TalkerFile>();

            using (MySqlConnection conn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString)) {
                using(MySqlCommand cmd = new MySqlCommand("SELECT fileId, fileName, contents, section, description FROM talkerFiles WHERE section = ?section ORDER BY fileName", conn)) {
                    cmd.Parameters.AddWithValue("section", section);

                    cmd.Connection.Open();

                    MySqlDataReader dataReader = cmd.ExecuteReader();
                    TalkerFile currentTalker;

                    while(dataReader.Read()) {
                        currentTalker = new TalkerFile();

                        currentTalker.FileId = long.Parse(dataReader["fileId"].ToString());
                        currentTalker.FileName = dataReader["fileName"].ToString();
                        currentTalker.Contents = dataReader["contents"].ToString();
                        currentTalker.Section = dataReader["section"].ToString();
                        currentTalker.Description = dataReader["description"].ToString();

                        talkerFiles.Add(currentTalker);
                    }

                    cmd.Connection.Close();
                }
            }

            return talkerFiles;
        }