There is absolutely a correlation between high glucose levels and the increased risk of infection, so I understand the concern. Most of the time, high glucose levels would be a sign of diabetes, so for them, yes, eating sugar will cause infection. There are other reasons people sometimes have high glucose levels, such as infection (that's not a typo, they cause each other), pregnancy, surgery, and certain medications, such as steroids.
From Wikipedia on steroid diabetes:
Treatment depends on the severity of the hyperglycemia and the estimated duration of the steroid treatment. Mild hyperglycemia in an immunocompetent patient may not require treatment if the steroids will be discontinued in a week or two. Moderate hyperglycemia carries an increased risk of infection, especially fungal, and especially in people with other risk factors such as immunocompromise or central intravenous lines. Insulin is the most common treatment
People with diabetes have a lot of difficulty keeping their glucose levels stable, so if they are frequently too high they will become sick more often. For healthy people, when we eat sugar, insulin is produced naturally by the body to bring the glucose level in the body down after the meal. It's important to remember that all carbohydrates are broken down into the same glucose molecules by the body. Some will be broken down faster and spike blood sugar levels, but there isn't a biochemical reason to assign special significance to table sugar, as opposed to fruit juice or white pasta, for example. WebMd explains in this article a diabetes diet.
So eating the cake didn't cause the relapse in your sore throat. Even if you had diabetes, it sounds like you only had one piece.
However, as a caveat, when you have an infection it's important to stay hydrated to recover faster and feel better. Liquids naturally thin and loosen mucus, so it helps relieve stuffiness and coughs. A stomach flu may make someone very ill if they become dehydrated, as well. Drinks with large amounts of sugar don't hydrate as well as water, so it is recommended to avoid soft drinks and sports drinks like Gatorade when you are sick, but it won't make a huge difference. Pedialyte is good if you have a very bad stomach flu.
According to WedMd:
What shouldn't sick children drink? Skip caffeinated drinks -- sick kids don't need it. As a rule, avoid sugary drinks or sodas. However, if a sweet drink is all your sick kid is willing to swallow, it may be OK to make an exception for now.