Posted on: 10/20/2012 12:43:13 AM | Views : 481

I have a bit of sample code that allows me to upload and download various documents (Word, PDF, etc) to a SQL Server Database varbinary(MAX) field.  It works fine but I'm a little confused about the basic principles. 
Actually it uses two fields, the varbinary and a varchar field that's used to store a string that reads 'application/vnd.ms-word' (or whatever the doc type.) 
My question is: What is this 'definition' and is there a simpler (and more generic) way to do this?
This is then used in the download in the following code (the 'definition' is going in the AddHeader call): 
Byte[] bytes = (Byte[])dt.Rows[0]["Data"];
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = dt.Rows[0]["ContentType"].ToString();
Response.AddHeader("content-disposition", "attachment;filename=" + dt.Rows[0][" ...

Go to the complete details ...