Пример #1
0
        //Gets the section ID of the user chosen template
        public void getRemoveSectionID(string sqlQuery, int TID)
        {
            //Create SQL Command object.
            SqlCommand     command = new SqlCommand();
            removeTemplate getID   = new removeTemplate();

            command.CommandType = CommandType.Text;
            command.CommandText = sqlQuery;

            //Adds the tempateID to the parameters
            command.Parameters.AddWithValue("@tempID", TID);

            //open the connection
            openConnection();
            command.Connection = connectionToDB;

            /*Performs a command that reads the database and finds rows that fits the condition of the sql statement
             * the execution of the command itself will be used to find and add the section ID's to the sectID list*/
            using (SqlDataReader reader = command.ExecuteReader())
            {
                /*the read command performs sequentially. When the row is found that fits the conditions of the sql statement,
                 * add that sectionID to the temporary list*/
                while (reader.Read())
                {
                    sectOriginalID.Add(reader.GetInt32(0));
                }
            }

            //Closes the Database Connection.
            closeConnection();

            //turns the sectID list equal the temporary list
            getID.turn_to_Remove_Section_ID(sectOriginalID);
        }