display documents in asp-page thats stored in database

Visual Studio170
Hi all,



First of all I do have to admit that I?m not sure If I?m in the right

NG .. if not I do apologize.



I have done an asp page that upload small files (different office

document and small images) into my database. The upload part is working

just fine.



My problem is when I want to display the docs.

It works fine if for example I do like this:

< --------->

response.Expires = 0

response.Buffer = True

response.Clear

response.contentType = "application/pdf"

Response.BinaryWrite( rs("img_data") )

< --------->

The problem is that if I do like above I need to know what kind of file

type (in the example ?application/pdf?) that I expect and I would like

so script to check and decide that for me.



I have a field in me table that store the application type so all that I

need to now is how I should check, right?



< ----- -->

Set rs = dbconn.Execute ("SELECT img_pk, img_data, img_contenttype FROM

image WHERE img_pk='1' ")



if rs("img_contenttype") = "application/pdf" then

response.Expires = 0

response.Buffer = True

response.Clear

response.contentType = "application/pdf"

Response.BinaryWrite( rs("img_data") )

end if



if rs("img_contenttype") = "application/msword" then

response.Expires = 0

response.Buffer = True

response.Clear

response.ContentType = "application/msword"

Response.BinaryWrite( rs("img_data") )

end if



if rs("img_contenttype") = "application/vnd.ms-excel" then

response.Expires = 0

response.Buffer = True

response.Clear

response.ContentType = "application/vnd.ms-excel"

Response.BinaryWrite( rs("img_data") )

end if



if rs("img_contenttype") = "image/pjpeg" then

response.Expires = 0

response.Buffer = True

response.Clear

response.ContentType = "image/pjpeg"

Response.BinaryWrite( rs("img_data") )

end if



< ----->

Above is my last attempt to make it work, but .. I receive this in my

web browser:

<font face="Arial" size=2>

<p>Response object</font><font face="Arial" size=2>error 'ASP 0106 :

80020005'</font>

<p>

<font face="Arial" size=2>Type Mismatch</font>

<p>

<font face="Arial" size=2>show.asp</font><font face="Arial" size=2>,

line 48</font>

<p>

<font face="Arial" size=2>An unhandled data type was encountered.

</font>



Is there anyone out there who can help me?

Thanks in advanced.



Regards,

Fredrik





*** Sent via Developersdex www.developersdex.com ***

Don't just participate in USENET...get rewarded for it!


-