IMHO the best way to tackle this, is to create the ID in your SQL DB as a bigint.
For the ID you set
Identity to yes
Identity seed to 1
Identity increment to 1
From now one you get 1 unique number each time you save.
HTH
Hans.
Infopath 2003 / Jscript