dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: how to store images in database

  1. #1
    Join Date
    Nov 2006
    Posts
    4

    how to store images in database

    Hi Friends,
    plz help me,
    i have a problem that i can easily store gif files from folders to DB using stream i want to know how to access images from DB Field

  2. #2
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    The simplest way is to save the data back to a file and then have the picture control reference the file. Once loaded into the picture control you can delete the file so that it does not hang around. Because the picture control does not care what the file name is you can even use the same name over and over, which makes your code simpler if it only has to create one file, load that file, then delete it.

  3. #3
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Ron do u mean the picture control can hold such a picture ?? what do u mean by :

    Quote Originally Posted by Ron Weller
    which makes your code simpler if it only has to create one file, load that file, then delete it.
    delete it ?
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  4. #4
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    Sure, both the picturebox control and the image control have Picture properties that you can load a file into. Once the file is loaded into the picturebox control you no longer need the file.
    Use LoadPicture() function to load the file:
    PictureBox1.Picture = LoadPicture("C:\gifFiles\temp.gif")

  5. #5
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    Near the beginning of the following thread:
    http://forums.devx.com/showthread.ph...090#post468090
    I gave an example of two functions I use to store and retreive image files, usually jpg, but gif files will work as well. These two functions use the ADODB.Stream object to read and write binary data to and from a field in a recordset.

  6. #6
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Yes for using at the load time only , but after you close the picture (loaded to the memory using loadpicture() function ) will not exist ..

    I mean this function load to the memory if you delete the picture you wont get it again after restarting the application ...
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  7. #7
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    True! but why would you want to? If you are just retreiving the image from your database and just need to view it, you would not want to leave the file on the hard drive. Now if you want the user to be able to save the file then that would be a different story. You would want to either provide a valid file name from your database or prompt the user for a file name and location. In this case you would not want to delete the file.

  8. #8
    Join Date
    Nov 2006
    Posts
    4
    thanks for your solution
    and i want to save images from database using stream

  9. #9
    Join Date
    Nov 2006
    Location
    India, Kerala
    Posts
    19
    here is a tutorial . i think it will help u

    http://www.stardeveloper.com/article...1033101&page=1

  10. #10
    Join Date
    Nov 2006
    Location
    India, Kerala
    Posts
    19

Similar Threads

  1. Upload images to Access Database
    By lotus123 in forum Database
    Replies: 5
    Last Post: 01-19-2007, 09:39 AM
  2. Store then Retrieve a File from a Jet Database Field
    By Larry Rebich in forum VB Classic
    Replies: 0
    Last Post: 02-10-2003, 02:39 AM
  3. Dynamic Update of DAO Using Model Database
    By Larry Rebich in forum vb.announcements
    Replies: 0
    Last Post: 08-26-2000, 12:56 PM
  4. Multiple Database Architecture
    By mholt28 in forum VB Classic
    Replies: 1
    Last Post: 06-05-2000, 11:21 AM
  5. Database questions
    By Kofi Brown in forum VB Classic
    Replies: 10
    Last Post: 05-08-2000, 09:13 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center