The program design here is not good because you try to mix two phases of the program that don't belong together. Loading the image and creating the sprites in random positions belongs into the game initialization phase. That you should do only once, before playing the game really starts, for example before the main game loop. The collision detection, on the other hand, belongs into the "playing the game" phase, inside the main game loop.
If all this code is inside the game loop, then if you manage to delete a sprite, in the next game loop you immediately recreate it, since your for loop runs again and makes all the sprites again with the dbSprite command. So the deleted sprites just keep coming back - although they may be immediately deleted again but that doesn't change the fact that the code needs some redesign. Here is a quick start:
// initialize once
for (int a = 100; a < 105; a++)
{
dbLoadImage("apple.bmp",a);
dbSprite(a,dbRnd(635),dbRnd(475),a);
}
// play game
while (LoopGDK())
{
for (int a = 100; a < 105; a++)
{
if(dbSpriteCollision(2,a))
{
dbDeleteSprite(a);
}
}
//... other commands and dbSync.
}
If that doesn't help, then we need to see more of the code to be able to help you more.
Maybe you can also have a look at the (more advanced) Dark Invaders tutorial for some game design ideas.