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

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

            //adds the sectionID to the command parameters
            command.Parameters.AddWithValue("@temporarySectId", SID);

            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 optin ID's to the opID 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 optionID to the temporary list*/
                while (reader.Read())
                {
                    optionOriginalID.Add(reader.GetInt32(0));
                }
            }

            //Closes the Database Connection.
            closeConnection();

            //Turns the opID list equal to the temporary list
            getID.turn_to_Remove_Option_ID(optionOriginalID);
        }