The order authorized by section 29-01-17 is a bar to another prosecution for the same offense.