The usual advice when configuring a router's "wireless" settings is to connect to it by ethernet cable, NOT WIRELESSLY. Otherwise, as soon as you save any changes, the connection will crash.
When you originally connected to the wireless network, a 'profile' will have been saved so that, in future, the adapter will connect automatically to the network when it is available. After setting up WEP/WPA encryption, you need to remove the existing 'profile' and go through the procedure to "Connect" again. You will be prompted to enter the encryption key and, once connected, a new 'profile' will be saved.
Remove profile screenshot click here