A SQL solution would be SELECT MAX(Position) + 1 FROM YourDatabaseTable WHERE TrackName = 'YourCurrentTrackName' Of course you'll probably want to parameterise the WHERE clause but it should give you the general idea. Alan