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

Response.Write("image file")

Status
Not open for further replies.

aarellano

MIS
Oct 22, 2007
168
US
Is there a way to have an image on a response write?

or could I even do something like this
<%=(Recordset1.Fields.Item("image").Value)%>

[/code]

Then in my "image" field on my db I would specify the link of the picture so I would put something like

/menu/pictures/picture1.jpg
 
Yes. I would use GetRows on my recordset and release the recordset object directly to avoid tying up your database.
Code:
<%
' do your query and get your data into a recordset
StrSQL = "Select pictitle, picpath from pics where " 'add your criterion here
Set rs = ObjCon.Execute(StrSQL)
' check for empty set then load array
if not rs.eof then
picarray=rs.getrows()
myTotal=ubound(picarray,2)
end if
rs.Close
set rs=Nothing
ObjCon.Close
Set ObjCon = Nothing
If myTotal > 0 then
for a = 0 to myTotal
%>
<div class="thumb"><img src="<%="pics/t/" & picarray(0,a) %>" alt="<%= picarray(1,a) %>"   />
<p><%= replace(picarray(1,a)," ","&nbsp;",1,1) %></p>
</div>
<%
next
end if
%>

All my thumbnails are generated at fixed size, so class 'thumb' is a simple CSS declaration
Code:
.thumb {
float:left;
border:none;
margin:0px;
height:150px;
width:139px;
}

This is simplified code for demo. You will want to use a stored procedure (or prepared statement as applicable) to get the recordset to avoid SQL injection attacks if you accept any user input to your query.

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
I have something going on that I really don't understand

Code:
<%

' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO" 
' DesigntimeType="ADO"
' HTTP="false"
' Catalog=""
' Schema=""
Dim MM_access_menu_STRING
MM_access_menu_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("\access_db\menu.mdb") & ";Jet OLEDB:Database Password="





Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_access_menu_STRING
Recordset1.Source = "SELECT *  FROM menubar"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>


if I do this
Code:
<img src="<%if(Recordset1.Fields.Item("category").Value=1)then response.Write((Recordset1.Fields.Item("imageon").Value))%>")%>
the image shows up, but if I change the

Value=2 or any other number than 1, the image does not show up. any idea of why this might be happening?
 
1. Are there any records in your table with a Category value of 2?
2. Any reason you are using If on the fetched recordset rather than using a Where condition in your query (as previously suggested)?
3. Any reason you have decided not to use GetRows?
4. Is there any relevance in this bit of code?
Code:
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
well, I am just a asp beginner and this is what I have learned so far. but I will try to follow your suggestions and see If I can write some code. I will post back with the new code


thansk for all the suggestions
 
I renamed the images to the product code number

<img src="../images/thumbnails/<%=SampleCode%>.jpg" alt="<%=SampleName%>&nbsp;<%=SampleType%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top