1. I guess you are using a Windows machine
2. I cannot begin to guess what version of Windows you are using
3. I cannot guess what version of iTunes you are using.
4. I guess you have no backup plan.

So, try this:
Launch iTunes and go to Preferences.
In the Devices section, you should find a check box marked "prevent iPods and iPhones from syncing automatically"
Should be all there is to it.
To get the music back onto the computer, take a look at this site:

Let us know how you get on