When you attach your android with your PC, you will get couple of options mentioning the way you may connect with the computer. In my case, I am using HTC Wildfire and it displays
I was also facing the problem the Question states and I have tested the way David Caunt answered but yet device was showing offline. *
I rechecked the options and found I selected the Disk Drive option. Then I changed the option to Charge only mode and again follow David Caunt's steps. I don't know why, but this time it worked for me.