2 Replies - 6313 Views - Last Post: 18 August 2011 - 03:53 AM Rate Topic: -----

#1 MrDreamCode  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-August 11

Hi does anybody know how to store images to a sql Database?

Posted 18 August 2011 - 12:55 AM

Hi does anybody know how to store images to a sql Database?
Is This A Good Question/Topic? 0
  • +

Replies To: Hi does anybody know how to store images to a sql Database?

#2 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: Hi does anybody know how to store images to a sql Database?

Posted 18 August 2011 - 03:39 AM

You would store the binary data into a BLOB column.

But it's best to not do this and instead simply store a path to the file in the database, pull it out in your application and read the file when you need to actually use the image.
Was This Post Helpful? 1
  • +
  • -

#3 paradoxia  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 163
  • Joined: 02-July 11

Re: Hi does anybody know how to store images to a sql Database?

Posted 18 August 2011 - 03:53 AM

View PostRudiVisser, on 18 August 2011 - 03:39 AM, said:

You would store the binary data into a BLOB column.

But it's best to not do this and instead simply store a path to the file in the database, pull it out in your application and read the file when you need to actually use the image.


Advantages of Storing BLOB Data in the Database

Storing BLOB data in the database offers a number of advantages:

* It is easier to keep the BLOB data synchronized with the remaining items in the row.
* BLOB data is backed up with the database. Having a single storage system can ease administration.
* BLOB data can be accessed through XML support in SQL Server 2005, which can return a base 64–encoded representation of the data in the XML stream.
* SQL Server Full Text Search (FTS) operations can be performed against columns that contain fixed or variable-length character (including Unicode) data. You can also perform FTS operations against formatted text-based data contained within image fields—for example, Microsoft Word or Microsoft Excel documents.

Disadvantages of Storing BLOB Data in the Database

Carefully consider what resources might be better stored on the file system rather than in a database. Good examples are images that are typically referenced via HTTP HREF. This is because:

* Retrieving an image from a database incurs significant overhead compared to using the file system.
* Disk storage on database SANs is typically more expensive than storage on disks used in Web server farms.



View PostRudiVisser, on 18 August 2011 - 03:39 AM, said:

simply store a path to the file in the database, pull it out in your application and read the file when you need to actually use the image



I also recommend this method.
For instance, if the image is found at the following location c:/pictures/bluenile.gif
First you need to add a record including the location field on a table in a database

Bonus
To retrieve the image using VB.net
1. you can drag the picture box control to the form
2. you need to write the code to connect with the database and to open it
3. you assign the cell which has the location in the database table to the picture box's ImageLocation property.

This post has been edited by paradoxia: 18 August 2011 - 03:58 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1