I followed all the instruction to unlock my ipad but then at the end it says that itunes was not able to connect to the ipad because it is locked with a password
Then enter the correct passcode to unlock it. If you have forgotten the passcode, you can put the device in recovery mode, but that will wipe the device with the exception of the iCloud activation lock, if applicable.