[thelist] Re: SQL Blob Field Image Error (Code)

Atkins, Chris CAtkins at patriothomes.com
Thu Jun 1 14:31:40 2000


> Here's the query:
> 
>      Response.Expires = 0
>      Response.Buffer = TRUE
>      Response.Clear
>      Response.ContentType = "image/gif"
> 
>      Set cn = Server.CreateObject("ADODB.Connection")
>      cn.Open "DSN=imgDB;UID=sa;PWD=;DATABASE=img"
>      Set rs = cn.Execute("SELECT img FROM img_01 WHERE img_id='0001'")
	[Atkins, Chris]  Have you tried stuffing the field value into a
variable?
	Instead of:
>      Response.BinaryWrite rs("img")
	[Atkins, Chris]
	theImage = rs("img")
	Response.BinaryWrite theImage

>      Response.End
> 
> and I call it like so
> <IMG SRC="SHOWIMG.ASP">
> Very simple
	[Atkins, Chris]  Also, you should really be checking if the
recordset
	is nothing or is at end-of-file before attempting to write it.

	Here are some other suggestions to track down where the problem
is...

	* Run the query in Query analyzer
	* Bring up showimg.asp in the web browser by itself
	* Use the code that Scott shared and have the script write an error
	message to the output stream if the first chunk is null.

	Just some suggestions.  It's hard to make any progress until one
identifies
	where the problem lies.  My variable-stuffing suggestion comes from
the fact
	that I have very similar working code with biggest difference being
that I set
	that variable... *shrug*

	Good luck!