Results 1 to 10 of 10

Thread: Saving Image in MS SQL 2000 Database

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Posts
    83

    Saving Image in MS SQL 2000 Database

    I want to save Image file in Database .. Data Type for i have used is image.

    how would i save it in a database...... and then retrive it on the form back.

    Also how can i then display it in Crystal report 8. one idea i have is OLE Object but not clear about it that how to use it..



  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Saving Image in MS SQL 2000 Database

    For saving it, see Beacon's tutorial in the database section.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Saving Image in MS SQL 2000 Database

    To store & save binary data (images or other files like that) use the image data type in the DB. Them look into the GetChunk and AppendChunk methods of the recordset object.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Member
    Join Date
    Jul 2005
    Posts
    33

    Re: Saving Image in MS SQL 2000 Database

    i think it will be more easier to save the path rather than save the image it self.so the type data in database is just text.( Just find this code today )
    this code need dirlistbox and filelistbox

    VB Code:
    1. Private Sub Form_Load()
    2. File1.path = App.path & "\images\" 'save all image in one folder named images and retrieve it
    3. End Sub
    4.  
    5. Private Sub OKButton_Click()
    6. path = File1.path + "\" + File1.FileName
    7. picture1.Picture = LoadPicture(path)
    8. End Sub

    hope this can help

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Saving Image in MS SQL 2000 Database

    Quote Originally Posted by little_mouse
    i think it will be more easier to save the path rather than save the image it self.so the type data in database is just text.( Just find this code today )
    this code need dirlistbox and filelistbox

    VB Code:
    1. Private Sub Form_Load()
    2. File1.path = App.path & "\images\" 'save all image in one folder named images and retrieve it
    3. End Sub
    4.  
    5. Private Sub OKButton_Click()
    6. path = File1.path + "\" + File1.FileName
    7. picture1.Picture = LoadPicture(path)
    8. End Sub

    hope this can help
    The only issue with this (and it can be a big one) is if/when the images get moved.

  6. #6
    Member
    Join Date
    Jul 2005
    Posts
    33

    Re: Saving Image in MS SQL 2000 Database

    yah,so that must put the image on folder images .

    is it comsume more space if saving the image on database?

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Saving Image in MS SQL 2000 Database

    Quote Originally Posted by little_mouse
    yah,so that must put the image on folder images .

    is it comsume more space if saving the image on database?
    A BLOB will always take more space than a string. There are a number of factors that would have to be considered before deciding on a direction, but probably the most important ones would be:

    How many images will be stored over a six month period? Over a year? More than a year?

    How long will the database be required to keep an image once it is stored?

    How much storage space do we have? What is the process/impact for getting more if we need it?

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Saving Image in MS SQL 2000 Database

    We use this method to distribute reports to our customers. When we were building the infrastructure, we knew that server information would vary from customer to customer, and we wanted the ability to limit who could make changes to the reports. So we created a table with an image field and we "stuff" our reports into it. We can then use that ReportID and a ScreenID (from another table) to link what reports are available from what screens.

    To deploy a report, we stuff it into our copy of their database (there's a spot in the admin section where this can be done) and then we script the binary information into a SQL Script. The customer then takes this "bin" script and runs it on their server. And viola, they then have the report.

    In your case, what happens when Joe Schmoe comes along and says, hey what are these doing here? and hits the delete button.... bad juju.

    I know a lot of people advocate just storing the path in the DB, but that can lead to problems down the road (not that it will, just that it can.)

    So you realy need to ask yourself what the risk is, and what to do if/should it happen, how to recover and what makes sense.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Saving Image in MS SQL 2000 Database

    We do much the same thing in my shop. We market RiskManagment software, and we have provided our customers with the ability to store police reports, physicians diagnostic reports, claims adjustment reports, legal depositions, etc, etc as well as things like photos taken at accident scenes. Our thing works pretty much the way Tg explained.

    Physically storing these files on a server, and just storing the paths could potentially create all sorts of problems, not the least of which is that most, if not all of these types of documents are confidential. If they were just sitting out there, anyone hacking into their network could grab them. (This is above and beyond the possibility of them being moved or deleted.)

    Up front, however, we tell our customers that this is going to require some hardware investment on their part as these will increase the storage requirements of their database.

  10. #10
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Saving Image in MS SQL 2000 Database

    Quote Originally Posted by vbcoder2
    I want to save Image file in Database .. Data Type for i have used is image.

    how would i save it in a database...... and then retrive it on the form back.

    Also how can i then display it in Crystal report 8. one idea i have is OLE Object but not clear about it that how to use it..


    Search through my posts: I have two samples - one to store a file (any file) and one to retrieve it.

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