Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

 

I was wondering what is the most of effective way for storing pictures in a database. One option that I was considering was, simple save the picture to a folder on the localmachine and then add the path to that picture into the database field. Otherwise, would it be more effective to use the datatype image in the database table.

 

Any other suggestions??

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted
Are these images that would be used on multiple machines? If so it doesn't make sense to store it in a folder on one machine so I would store it in the database. Also, what database?
Here's what I'm up to.
Posted
Sorry should have stated that it is a web project and I would be using a specific server.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

Most often, it is more efficient to store the path in the database. I notice that you said data type image, that sounds like MS SQL. Image is still just binary data. When you store images or binary data in a database, you have to convert it back to something that can be more useful. This is either done by creating a temporary file or memory stream to recreate the file from its binary form in the database. If you just store the path in the database, you cut out that step.

 

If you are using MS Access as the backend, then storing the picture is highly unrecommended because of the 2GB Max size.

 

With any database though, not just Access, storing binary data (images, or whatever) can cause severe database bloat. However, sometimes this is unavoidable and the binary data must be stored in the database.

 

 

Chester

____________________________________________

http://www.pophamcafe.com

I am starting a developers section, more tutorials than anything.

Posted

Will be using SQL Server 2000. I recon that it would be in my best interest to simple store a file path for the image in the database so as to reduce database size.

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

I was wondering what is the most of effective way for storing pictures in a database. One option that I was considering was, simple save the picture to a folder on the localmachine and then add the path to that picture into the database field. Otherwise, would it be more effective to use the datatype image in the database table.

 

Yes, you have 2 ways:

- store the image path

- store the byte array in a memo (or blob depending on the DBMS) that you can retrieve with

                   Bitmap bmp = new Bitmap(_image);
                   TypeConverter bmpc = TypeDescriptor.GetConverter(bmp.GetType());
                   return (byte[])bmpc.ConvertTo(bmp, typeof(byte[]));

 

With "old" tecnologies you colud also store the image as OLE-resource, but I deprecate it.

> NeoDataType.net <

Try my Free .Net Reporting Tool!

Posted
Unless you're worried about people linking to your images on there web site it's really not a great option to store images in a BLOB field as other have mentioned. I can think of some reasons not to, but nothing that is under 'normal' circumstances.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...