The only way to get a friend code is to go in the union room in the Pokemon center and use wifi with a friend and it willask do you want to exchange friend codes and say yes
Chat with our AI personalities
You can trade, battle, and have voice chats with your friends over Wifi in Pokemon Diamond/Pearl, but to do so you need to know your friends' Friend Codes, and your friends need to know your Friend Code.
In Jublife City
In any pokemon center go downstairs to the wifi club and get a pal pad then you will be able to enter your friend codes as well as view your own. Hope this helped :)
Yes using the Wireless connection for the DS or Nintendo wifi connection.
You must trade it with a friend, with WIFI-connection in Jublife city(trade building) or transfer it from Pokemon ranger.