Can't you store the images after the insert? Using latest ProductID +1 may not work consistently. The best solution is to do the image inserts after the master insert. The newly inserted ID will be saved in the session and can be referenced on the same page after the insert for the image inserts.