See the following post at my weblog: http://weblogs.asp.net/cazzu/archive/2003/08/27/25568.aspx.
Even if you're not thinking in an ASP.NET IHttpHandler, the code will be useful. Translating to VB.NET should be trivial.
Note that the file in its entirety is stored in the DB, therefore, it doesn't matter if it contains images, visio drawings or embedded excel files.
This was first published in February 2004