How to retrieve an image from a database? and other problems regarding ASP

Discussion in 'C#' started by breadstix2189, Aug 18, 2008.

  1. #1
    Good day to all of you guys... I'm new to ASP programming, and I'm having problems with my ASP project

    First
    If i don't input anything in the search box, it will display an error...

    Second
    I want to retrieve an Image from the database, but it wont show...

    Lastly
    In my text box, I declare the value so that the user wont input anything... but as i confirm it... there are no values inserted in the database...

    And with these problems, I have no idea to solve any of these...
    Can somebody help me with this? Thanks in advance... >_<

    By the way here's the code
     

    Attached Files:

    breadstix2189, Aug 18, 2008 IP
  2. VishalVasani

    VishalVasani Peon

    Messages:
    560
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,

    Below code may help to solved your issue related image display(second issue):
    
    set Connection = server.createobject("ADODB.Connection")
        Connection.Open "DatabaseDSN", "UserName", "Password"
        set Result = server.createobject("ADODB.Recordset")
        sql = "SELECT * FROM  studinfo  WHERE StudentIDNo='" & StudentIDNo "'"
        Result.Open sql, Connection, adOpenKeyset
        if not (Result.eof and Result.bof) then
            Image = Result("Picture").GetChunk(1024000)
            Response.ContentType = "image/bmp"
            Response.BinaryWrite Image
        else
            Response.Write "ID '" & StudentIDNo & "' not found in DB."
        end if
        Result.Close
        Connection.Close
    
    Code (markup):
     
    VishalVasani, Sep 4, 2008 IP