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

How to get image file in SQL DB

Status
Not open for further replies.

timob12

Programmer
Mar 13, 2002
3
0
0
US
Hello:
I have a SQL DB with a Product table.

The columns in the table are desc., price, etc....I know very little ASP but have been using sample ASP code and plugging it in to make my pages work. I have everything running ok but I can't find a example of how to return the picture in that product row. I can get every other value fine because the values are in the respective cells but I don't understand how to properly code my asp productresults.asp to return the image related to the product. I have a value,.... for example car.jpg in my product_picture cell but obviously don't want the value "car.jpg" returned but rather I want the picture of car.jpg returned.

Again I have very little experience with ASP any help of a site that may explain this or any other help is appreciated. I hope I explained myself properly.

Here is what I have so far (my productresults asp page):
****The strPictureFileName is what I can't get working. All other variables are returning values ok.


<!--#include virtual=&quot;/lib/all_include.asp&quot;-->
<%

lngProductID = Request.QueryString(&quot;productID&quot;)



Sub showProduct
Response.Write listProduct(lngProductID)
End Sub



Function listProduct(lngProductID)
If lngProductID = &quot;&quot; Then Exit Function
Dim lngParentID,strName
Set myDB = New database
Set objRS = Server.CreateObject(&quot;Adodb.Recordset&quot;)
With myDB.dbCommand(&quot;sp_GetProductByID&quot;)
.Parameters(1) = lngProductID
.Execute
strPartNumber = .Parameters(2)
strName = .Parameters(3)
strDescription = .Parameters(4)
curPrice = .Parameters(5)
strPictureFileName = .Parameters(6)
End With
strOut = &quot;&quot; &_
&quot;<table border='1' cellpadding='0' cellspacing='0'>&quot; &_
&quot; <tr>&quot; &_
&quot; <td rowspan='2'><table border=0>&quot; & strDescription & &quot;</table></td>&quot; &_
&quot; <td>Model Number:</td><td>&quot; & strPartNumber & &quot;</td>&quot; & _
&quot; </tr>&quot; &_
&quot; <tr>&quot; &_
&quot; <td>Price:</td><td>&quot; & curPrice & &quot;</td>&quot; &_
&quot; </tr>&quot; &_
&quot;</table>&quot;


Set myDB = Nothing
Set objRs = Nothing
listProduct = strOut
End Function


%>
 
You could store the path to the file, or the name of the file in the table and the actual image on the HDD.

And you display the image like this:
response.write &quot;<img src='&quot; & rsData(Path) & &quot;'>&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top