Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2003
    Posts
    160

    Unanswered: How to display images from ms access onto asp form from a table

    Hi! I am new to asp and here is my question.

    I have an MS Access datacase,In one table I stored all the information regarding one truck, including 4 images for each of the truck.The data type for images are OLEObject.

    I am sending the information into the table using MS Access Form.and the images using insert object.Now the problem is they are not displaying on an ASP form, but the text is displaying ok.Any help!

    Thanks!
    Vad

  2. #2
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    You need to have a seperate page which returns the data from the image field as data rather than text.

    Just have a page which returns the data on its own - i.e. with no html and then from the page with the form;
    Code:
    <img src="page_which_returns_data_on_its_own.asp?id=id_of_record" />

  3. #3
    Join Date
    Aug 2003
    Posts
    160

    How to display images from ms access onto asp form from a table

    I am fairly new.So Here I am giving the code I wrote.

    <%
    dim adopenkeyset
    adopenkeyset=1
    dim adlockoptimistic
    adlockoptimistic=3
    set conn1=server.createobject("ADODB.Connection")
    conn1.connectionstring="Provider=Microsoft.jet.ole db.4.0; Data source = C:\temp\ILLIANA-Truck.mdb"
    conn1.open
    set rst = server.createobject("adodb.recordset")
    rst.activeconnection=conn1
    rst.open "select * from VehicleDetails",conn1,adopenkeyset,adlockoptimisti c

    Do While Not rst.EOF
    Response.Write "<TABLE BORDER='0' align='center' width='657' height='332' bgcolor='#F3F3F3'><TR><TD width='400' height='332'><i><font face='Times New Roman' size='4'>"

    Response.Write"<b>Stock#: </b>"
    Response.Write rst("Stock#")
    Response.Write"<br><b>Year: </b>"
    Response.Write rst("Year")
    Response.Write"<br><b>Make: </b>"
    Response.Write rst("Make")
    Response.Write"<br><b>Model: </b>"
    Response.Write rSt("Model")
    Response.Write"<br><b>Mileage: </b>"
    Response.Write rst("Mileage")
    Response.Write"<br><b>Serial Number: </b>"
    Response.Write rst("Serial#")
    Response.Write"<br><b>Purchase Date: </b>"
    Response.Write rSt("Purchage Date")
    Response.Write"<br><b>Purchase From: </b>"
    Response.Write rst("Purchage From")
    Response.Write"<br><b>Cost: </b>"
    Response.Write rst("Cost")
    Response.Write"<br> <b>Transportation: </b>"
    Response.Write rst("Transportation")
    Response.Write"<br><b>Engine: </b>"
    Response.Write rst("Engine")
    Response.Write"<br><b>Engine Brake: </b>"
    Response.Write rst("Engine Brake")
    Response.Write"<br><b>Transmission: </b>"
    Response.Write rst("Transmission")
    Response.Write"<br><b>Sleeper: </b>"
    Response.Write rst("Sleeper")
    Response.Write"<br><b>Suspension: </b>"
    Response.Write rst("Suspension")
    Response.Write"<br><b>GVWR: </b>"
    Response.Write rst("GVWR")
    Response.Write"<br><b>Front Axle Capacity: </b>"
    Response.Write rst("Frt Axle Capacity")
    Response.Write"<br><b>Rear Axle Capacity: </b>"
    Response.Write rst("Rear Axle Capacity")
    Response.Write"<br><b>Fornt Wheels: </b>"
    Response.Write rst("Front Wheels")
    Response.Write"<br><b>Rear Wheels: </b>"
    Response.Write rst("Rear Wheels")
    Response.Write"<br><b>Tire Size: </b>"
    Response.Write rst("Tire Size")
    Response.Write"<br><b>Turbo: </b>"
    Response.Write rst("Turbo")
    Response.Write"<br><b>Air Conditioning: </b>"
    Response.Write rst("Air Conditioning")
    Response.Write"<br><b>Power Steering: </b>"
    Response.Write rst("Power Steering")
    Response.Write"<br><b>Tank Capacity: </b>"
    Response.Write rst("Tank Capacity")
    Response.Write"<br><b>Truck Type: </b>"
    Response.Write rst("Truck Type")
    Response.Write"<br><b>Floor material: </b>"
    Response.Write rst("Floor material")
    Response.Write"<br><b>Refrigerated: </b>"
    Response.Write rst("Refrigerated")
    Response.Write"<br><b>Color: </b>"
    Response.Write rst("Color")
    Response.Write"<br><b>Interior: </b>"
    Response.Write rst("Interior")
    Response.Write"<br><b>Tilt: </b>"
    Response.Write rst("Tilt")
    Response.Write"<br><b>Cruise: </b>"
    Response.Write rst("Cruise")
    Response.Write"<br><b>Radio: </b>"
    Response.Write rst("Radio")
    Response.Write"<br><b>Telescopic Column: </b>"
    Response.Write rst("Telescopic Column")
    Response.Write"<br><b>Cab Axle: </b>"
    Response.Write rst("Cab Axle")
    Response.Write"<br><b>Selling Price: </b>"
    Response.Write rst("Selling price")
    Response.Write"<br><b>Image1: </b>"
    Response.Write rst("Image1")
    Response.Write"<br><b>Image2 </b>"
    Response.Write rst("Image2")
    Response.Write"<br><b>Image3 </b>"
    Response.Write rst("Image3")
    Response.Write"<br>"
    Response.Write"<br>_______________________________ ________________________________<br><br>"
    rst.movenext
    Loop
    Response.Write "</font></i></TD></TR></table>"
    %>

    Where I have to create another page.Could give some sample code how to do that.Thank u very Much.
    Vad

  4. #4
    Join Date
    Sep 2003
    Posts
    6

    Image

    Vad,

    An image is a couple of 3 informations : the image name, the image data an dthe image type. You have to store all those informations in your database (esp if you have different kind of images stored there... jpg, gif)
    Then you need to create a file that brings teh image out of the database and you link to this page as you link to a normal image <img scr="showimage.asp" border....>

    now here is a code that can do this:

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%Option Explicit%>
    <!-- #include file="connection.asp" -->
    <!-- #include virtual="/adovbs.inc" -->
    <% response.Buffer = True


    dim strSQL, objRS_DispIm
    strSQL = "Select IMGDATA, IMGTYPE from TABLENAME where ID = '" & request("id") & "'"
    set objRS_DispIm = server.CreateObject("ADODB.REcordset")
    objConn.open
    objRS_DispIm.open strSQL, objConn, 2, 4
    if (objRS_DispIm.EOF and objRS_DispIm.BOF) then
    response.Write("Image not found")
    else
    response.ContentType = trim(objRS_DispIm("IMGTYPE "))
    response.BinaryWrite objRS_DispIm("IMGDATA")

    end if
    objRS_DispIm.close
    set objRS_DispIm = nothing
    objConn.close
    set objConn = nothing
    %>

    Save this code into a file called ShowImage.asp and then call it as I said <img scr = "ShowImage.asp?id=idnumber"> Of course you replace ID with whatever you need to find the exact image you wanna display.

    I hope it works. For me it does

  5. #5
    Join Date
    Aug 2003
    Posts
    160

    How to display images from ms access onto asp form from a table

    Hi I worte the code exactly the same with the name changes but it is giving me errors.

    Here Is the code

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%Option Explicit%>
    <% response.Buffer = True
    dim strSQL, objRS_DispIm, objConn
    strSQL = "Select Image1 from VehicleDetails where Year = '" & request("Year") & "'"
    set objRS_DispIm = server.CreateObject("ADODB.Recordset")
    objConn.open
    objRS_DispIm.open strSQL, objConn, 2, 4
    if (objRS_DispIm.EOF and objRS_DispIm.BOF) then
    Response.Write("Image not found")
    else
    Response.ContentType = "image/jpg"
    response.BinaryWrite objRS_DispIm("Image1")

    end if
    objRS_DispIm.close
    set objRS_DispIm = nothing
    objConn.close
    set objConn = nothing
    %>


    Thank U
    Vad

  6. #6
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    What errors? Please clarify.

  7. #7
    Join Date
    Aug 2003
    Posts
    160

    displaying imags from database

    Thank U very Much I got my problem fixed.
    Vad

  8. #8
    Join Date
    Oct 2002
    Posts
    48

    Re: displaying imags from database

    VAD,

    It would be nicer, if you will mention, how you fix your problem.

    Thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •