I probably should've given more information on what I was doing. I already had my stuff for generating rooms in place, and what I was having them do is choose a random, empty location on the map, and then choosing a room from a list of static room designs (rather than having the room design itself randomly generated).
Anyway, what I ended up doing was marking one room as "connected," and then having that room connect to the nearest room to it, and then marking that room as connected and moving on.
To prevent the dungeon from becoming extremely linear and boring, every room has a chance to have more than one hallway generated for it, and hallways after the first one do not care about whether the rooms they connect to are marked as connected, and they do not mark new rooms as connected, so it's still easy to go through them one at a time.
Since exactly one room has its hallways done for each time a room is marked as connected, that means that once all rooms are marked as connected there is only one last room that has not had its own hallways generated, so the loop makes some for that last room, not worrying about whether its targets are connected to the rest already, since they all are.
Anyway, thanks for your advice everyone, and hopefully my explanation of what I did can help someone else who has trouble with this.