Results 1 to 4 of 4

Thread: Crash Course in Images

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    207

    Crash Course in Images

    Hi,

    For so long now I cannot figure out how to read files from a database and how to upload a file to DB.

    If anyone knows how to please could you assist me with some simplified samples.

    Thanks.

  2. #2
    Addicted Member
    Join Date
    May 2005
    Posts
    137

    Re: Crash Course in Images

    I am by no means an expert but this is how i did the saving in a vb app using Access as the backend

    the field in access was set to a ole object i think

    you shouldn't have to change much for ASP


    Code:
        
    Dim mystream As New ADODB.Stream
        Set mystream = New ADODB.Stream
        
        mystream.Type = adTypeBinary
        RS.CursorLocation = adUseClient
         
        RS.ActiveConnection = cn
        
        RS.Open "SELECT imgName,Image FROM tblImages WHERE imgName = ''" 
    
        RS.AddNew
        mystream.Open
        mystream.LoadFromFile "Image location"
        
        RS.Fields("imgName") = "ImageName"
        RS.Fields("Image") = mystream.Read
        RS.Update
        
        RS.Close
        mystream.Close

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    207

    Re: Crash Course in Images

    Thanks ooKmonkey.. I will be using VB.NET to place the image into the DB and using ASP to read it back onto a website.

    I could use a tool to do all this but I rather learn and know how its accomplished. I will give it a go and write back with my result.

    Thanks again

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    207

    Re: Crash Course in Images

    Ok. Here is what I did.

    I created a Access DB this is what I am trying to do in ASP to view the picture.

    It shows all jibberish, which I guess its right, but now what is next? Thanks

    Code:
    <!-- #include file="adovbs.inc" -->
    <%
    	response.Buffer = true
    	dim con, com, rec
    	
    	set con = server.CreateObject("ADODB.Connection")
    	set com = server.CreateObject("ADODB.Command")
    	set rec = server.CreateObject("ADODB.RecordSet")
    	
    	con.open "Provider=Microsoft.JET.OLEDB.4.0; Data Source = D:\UITS\DB_Cars.mdb" 
    	com.activeconnection = con
    	com.commandtype = adCMDText
    	com.commandtext = "SELECT * FROM Images"
    	rec = com.execute
    
    	response.ContentType = "images/jpeg"
    	response.BinaryWrite(rec("ImageFile"))
    %>
    Last edited by TURKINATOR; Oct 24th, 2007 at 06:06 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width