After the 9th season Christmas special, we now know how River got the screwdriver.
But how did River’s neural relay end up in there, and how did it stay online for all that time, waiting to be uploaded?
"You always knew how I was going to die" - River Song, Forest of the Dead
"The thing is, future me had all that time to think about. To think of a way to save her" - The Doctor, Forest of the Dead
The Doctor put the neural relay in that screwdriver when he made it, knowing he would be giving it to River Song before she went to the library.
That neural relay was activated when she zapped herself in the library, so it was only "online" for a few minutes while The Doctor ran to the central server.
I have to say I disagree with DisturbedNeo's answer. When you watch the episode, after she zaps herself, The Doctor is handcuffed to a pipe, with no one else there. With Mr. Lux distracted by all the people who suddenly returned, I don't think the first thing he did was run back to see The Doctor and River.
Furthermore, before the conversation where he figures out what's in the screwdriver, you see that they're beginning to evacuate the people that were saved. Seeing as though they had no idea that the people were even going to be alive, I doubt very much they had ships ready for them to teleport to (admitted, maybe it's an interplanetary teleportation network, and that's irrelevant). They would presumably have to do a bit of work coordinating things (though I'll admit that CAL might be able to help now that she's able to think clearly), during which time Donna tried to find Lee:
DOCTOR: Any luck?
DONNA: There wasn't even anyone called Lee in the library that day. I suppose he could have had a different name out here, but, let's be honest, he wasn't real, was he?
So, to sum up, after River zaps herself, the following needed to happen:
That said, I think part of the explanation can be found in the following quote:
DOCTOR: There's a neural relay in the communicator. Lets you send thought mail. That's it there. Those green lights. Sometimes it can hold an impression of a living consciousness for a short time after death. Like an afterimage.
ANITA: My grandfather lasted a day. Kept talking about his shoelaces.
So, we know that some people last longer than others.
Also, given that Ms. Evangelista was not very bright, perhaps her pattern wasn't as strong to begin with. If that does have something to do with it, then I think River Song, a chosen companion of The Doctor, would be a very strong pattern.
Furthermore, this was a neural relay that The Doctor himself put into the screwdriver. Given his own knowledge of psychic phenomena, technology, brains, and, well, practically everything, I think it's safe to say he might know a few tricks to keep the pattern from degrading as quickly which could incorporate into the design.
Together, I think these factors allowed River's pattern to survive.
I don't think the relay in the screwdriver is the same relay as in the suit. I suspect that they are different relays.
The one in the suit gets fried (or otherwise expires normally) after River dies.
The one in the screwdriver, on the other hand, is safely on the floor out of reach of the zap (and the doctor).
The sonic-embedded relay has been with River for some time (I don't think we know how long it was between these two events) and so, presumably, has had a good long time to get a solid imprint of River. (Assuming, as I commented on DisturbedNeo's answer, that The Doctor activates the relay when he scans River in "The Husbands of River Song".)
Then it just needs to last from the moment of the zap (when River dies) to when The Doctor plugs it into the computer which, as I indicated in a comment on childofsoong's answer, is less than a day later.
And we know, as childofsoong shows with a quoted bit of dialog, relays can last a day at least (and presumably most people aren't The Doctor or River or have their relays active for as long as River might have).