Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display image stored in BLOB Field

Status
Not open for further replies.

AndyApp

Programmer
Dec 20, 2001
259
GB
I have copied the information from the Microsoft Knowledge Base (question 173308) and set it up exactly as was stated in the article.

However when i run the page that looks at the 'showimg.asp' page it just comes up with a image placeholder. And if I run the page that is supposed to just display the image (showimg.asp) I get:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/PaymentAndReceiptASP/SHOWIMG.asp, line 11

Does anyone know why? "Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway" - Jim Davis (Garfield)
 
I found that trying to show BLOB objects is too much trouble. What I do is instead of storing the image in the database as a BLOB object, I store the path to the image on the server as text (e.g. &quot; I select that from the database and just write it out in the <img src> tag. It's much easier to deal with images that way.
 
dds82 thats a 'last resort' i'm afraid. The database is also accessed by MSAccess so the images really need to be in there.

Gorkem:

--showimg.asp--
<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<%
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

Response.ContentType = &quot;image/gif&quot;

Set cn = Server.CreateObject(&quot;ADODB.Connection&quot;)

cn.Open &quot;DSN=myDSN;UID=sa;PWD=;DATABASE=pubs&quot;
Set rs = cn.Execute(&quot;SELECT logo FROM pub_info WHERE pub_id='0736'&quot;)

Response.BinaryWrite rs(&quot;logo&quot;)
Response.End
%>

-----------
calling the image from a different page:

<IMG SRC=&quot;SHOWIMG.ASP&quot;>

the image should show through just running showimg.asp

thanks &quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
You say you copied the example exactly? That may be the issue. Your error &quot;Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/PaymentAndReceiptASP/SHOWIMG.asp, line 11&quot; means that the ASP server could not find the appropriate data source to make the connection to your database.

In your code, you have:
cn.Open &quot;DSN=myDSN;UID=sa;PWD=;DATABASE=pubs&quot;

If you changed this code so as to not reveal your real connection info, then disregard the following. Otherwise, you need to make sure you have the DSN &quot;myDSN&quot; registered in your system with the correct username and password, otherwise your asp page will not be able to connect to your database.
 
The 'pubs' database is one that is installed with SQL server or some other Microsoft product. It is on the server we are using. We have even changed it over to the Northwind database and our own. None of which work. &quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top