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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Result returns 'True' instead of image!

Status
Not open for further replies.

Webflex

Technical User
Apr 20, 2001
101
GB
Hi

The following is supposed to display an image but just returns 'True' instead. Any ideas?

TIA

Code:
<%
option explicit
dim useraction
dim dsn,sql,conn,rs,flag,color,x
dim fname,lname,tel,mobile,init,dept,id,picture
id=request(&quot;id&quot;)
useraction=request(&quot;action&quot;)
dsn=&quot;DBQ=&quot; & Server.Mappath(&quot;../db/phdb.mdb&quot;) & &quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;
set conn=server.createObject(&quot;adodb.connection&quot;)
conn.open dsn
select case useraction
case &quot;display&quot;
sql = &quot;select * from users where id=&quot;&id
set rs = conn.execute(sql)
lname=rs(&quot;lname&quot;)
fname=rs(&quot;fname&quot;)
tel=rs(&quot;tel&quot;)
mobile=rs(&quot;mobile&quot;)
init=rs(&quot;init&quot;)
dept=rs(&quot;dept&quot;)
picture=rs(&quot;picture&quot;)


	if rs.eof and rs.bof then
		response.write &quot;No Record Found&quot;
	else
		response.write &quot;<table border=0 align=left><th align=left>Last Name</th><th align=left>First Name</TH>&quot;
		response.write &quot;<th align=left>Tel</TH>&quot;
		response.write &quot;<th align=left>Picture</TH>&quot;
		do while not rs.eof
		if flag=0 then
			flag=1
			color=&quot;#DFEFFD&quot;
		else
			flag=0
			color=&quot;#DDEOE3&quot;
		end if

		response.write &quot;<TR bgcolor=&quot;& color & &quot;><TD>&quot;
		response.write RS(&quot;lname&quot;) & &quot;</td><td>&quot; & RS(&quot;fname&quot;) & &quot;</td><td>&quot; 
		response.write RS(&quot;tel&quot;) & &quot;</td><td>&quot;
		response.write (&quot;<img src=&quot;&quot;&quot; & RS(&quot;picture&quot;) & &quot;&quot;>&quot;&quot;)
		rs.movenext
		x=x+1
	loop
	
	'response.write &quot;<tr><td colspan=7>Total Records : &quot; & x & &quot;</table>&quot;
	
	rs.close
	conn.close
	set conn=nothing
	end if

set conn = nothing
%>

<%end select%>
 
I assume from your code that the Picture column of the table contains an image? If it does you have to extract the image from the database using :

MyResultSet!Picture.GetChunk(nSize) method.

This is done within a loop until the full image size is extracted. Eg.
Dim sSize as String
Dim lColSize as Long
lColSize = MyResultSet!Picture.ColumnSize
if lColSize = -1 then
// Size not avail so read it block at a time
sTemp = MyResultSet!Picture.GetChunk(64)
Do
s = s & sTemp
sTemp = MyResultSet!Picture.GetChunk(64)
Loop While Len(sTemp) > 0
else
if lColSize > 0 Then
// Size is there so slurp it in.
s = MyResultSet!Picture.GetChunk(lColSize)
End if
End if


HTH




HTH
William
Software Engineer
ICQ No. 56047340
 
No the database picture field is formatted as text and contains the reference in the format images/imagename.jpg, I have tried formatting as URL and get the same result.
 
What result do you get when you execute the same SQL in Access?

William
Software Engineer
ICQ No. 56047340
 
OK never done that before, which particular SQL and how?
 
Start up Access and execute the SQL you are using in your ASP page select * from users where id = x. Remembering to replace x with a known Row ID.

This should return the same information you expect in your ASP Page. If it does not I.E. you get a path returned in the Picture column then the fault is with in your ASP code.

HTH
William
Software Engineer
ICQ No. 56047340
 
sorry to be particularly dense but where in access do I enter the query?
 
I don't use Access but IMSMC you can Select the Stored Procedures option then click the Design Button. Enter your SQL and run it. Then dump it when it ask you to save when you exit.

If you don't have the SP option use the view option instead.
Remembering in both instances to select the SQL View from the left most button on the toolbar.
William
Software Engineer
ICQ No. 56047340
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top