You cannot give yourself GD by eating sweets however you could have had a higher level of glucose in your body becuase of the eating sweets. I've done that and failed the 1 hour glucose test with all but 1 of my pregnancies.
Lay off the sweets for several days before your next test. Then see what it shows. I have always passed my 3 hr, I just really have to watch my sugar intake in the days leading up. Give it several days beforehand, not just one or two.