예제 #1
0
        public List<ModuleCL> SeclectMod()
        {
            string query = "SELECT * FROM module";
            List<ModuleCL> allMod = new List<ModuleCL>();

            //Open connection
            if (this.OpenConnection() == true)
            {
            //Create Command
            MySqlCommand cmd = new MySqlCommand(query, connection);
            //Create a data reader and Execute the command
            MySqlDataReader dataReader = cmd.ExecuteReader();

            while (dataReader.Read())
            {
                Int32 ModuleID = dataReader.GetInt32(0);
                String ModuleName = dataReader.GetString(1);
                Int32 ModuleHours= dataReader.GetInt32(2);
                Int32 ReqModHRS = dataReader.GetInt32(3);

                ModuleCL mod = new ModuleCL(ModuleID, ModuleName, ModuleHours, ReqModHRS);
                allMod.Add(mod);

            }
            //close Data Reader
            dataReader.Close();

            //close Connectionon
            this.CloseConnection();
            }
            return allMod;
        }
예제 #2
0
        public void insertMOD(ModuleCL Mod)
        {
            string qureyMod = "INSERT INTO module(moduleName, moduleRequiredHours ,moduleTaughtHours ) VALUE('" + Mod.ModuleName + "','"
            + Mod.ReqModHRS+"','"+ Mod.ModHrs+ "')";

            if (this.OpenConnection() == true)
            {
            //create command and assign the query and connection from the constructor
            MySqlCommand cmd = new MySqlCommand(qureyMod, connection);
            //NOTE!! throws  exaption as to the  defluat data
            //Execute command
            cmd.ExecuteNonQuery();

            //close connection
            this.CloseConnection();
            }
        }