The key to understanding this quote is to know what "vainly" and "surcease" mean. To do something vainly means to do it without success: I vainly searched for my quarter that rolled down the street rain drain. If something undergoes surcease, it stops, it ceases. Now let's try that line again:
Without success had I tried to borrow from my books cessation (ceasing) of my sorrow.
The speaker is saying that while in deep sorrow, s/he turned to their books--philosophy, religion, etc--to give them the wisdom, strength, joy, courage, or even distraction that would put a stop to the sorrow: in the end of searching in books, the sorrow was still there.