My 2nd gen iPod Touch (which was missing for a long time, until I found it under the microwave) can connect to the internet, so I believe the answer is yes, to both iPods. However, neither of those models can connect to the App Store or to the iTunes Store.
Bearing in mind the above, are you saying that you cannot connect to your Wi-Fi, or you are connected but you are unable to access either the App Store or the iTunes Store?
To check whether you can connect to the internet, use Safari and look for something simple online (just search for a word or something). If the issue is that your iPod cannot even connect to your Wi-Fi, go onto the next steps.
If you cannot even connect to your Wi-Fi, let's see if we can identify the issue. We'll use your 2nd gen model as that's the one I have so we'll be using identical menus:
- go into Settings and look at the Wi-Fi option. If the word Off is shown, go into the option and turn it on. It may require a long-hold on the button, rather than sliding it
- once Wi-Fi is on, does your network appear on the list that is headed Choose a Network...? If not, make sure that you are in range of your router
- if your iPod does not automatically connect to the network (it will show a tick next to the name), tap it to select it and you should then be asked to type in the password for the router (not your Apple ID). Note that the password will be case sensitive, but keyboard shows the letters in capitals, but it only types a capital letter if the shift key (the arrow on the left of the keyboard) is solid white*
- if the iPod was already connected to the correct network, but you cannot get online, try tapping the arrow icon at the end of the router name line and then tap the Forget this Network button shown at the top of the window
- if you had to use the Forget this Network option, your router should still appear on the Choose a Network list, but without the tick (checkmark). Select it and put in the password*
* the shift key on the iPod's keypad works as follows:
- outline of an arrow in white - types the next character in lowercase
- solid white glowing arrow - types the next letter as a capital letter
- solid white arrow, on blue "key" - types all characters in uppercase until turned off