The two DS's could not be close enough together. Remember DS WiFi Communications were terminated in 2014, so you cannot trade online.
You could be using an emulator, in which case there could be plenty of reasons why it's not working.
Your cartridge could be older, and have problems. One of my cartridges acts that way.
Are both cartridges the same language? That might impact trading, but I'm not sure.
It's likely that because Gen 4 is old and that the Nintendo WFC used in Gen 4 has been proven many times to be finicky, it's probably just a tech error. Try leaving and re-entering the room, or rearrange the Pokemon in your party.