Hi,
I am curious. Is there any built-in functionality in asp.net 2.0 or vs 2005 to ease this insert image to sql server 2005?
I had seen some ways through here, and I am looking for the best technique. I prefer to learn to code than using any 3rd party sofware :P
http://aspalliance.com/articleViewer.aspx?aId=138
Any help?
Thanks :)
Check out http://www.codeproject.com/cs/database/UploadPicturesSQLServer.asp
and
http://sqlservergems.blogspot.com/2006/03/how-to-insert-image-into-sql-server.html
weehyong:Check out http://www.codeproject.com/cs/database/UploadPicturesSQLServer.asp and http://sqlservergems.blogspot.com/2006/03/how-to-insert-image-into-sql-server.html
feelite:but just one question, it seems that the openrowset function cannot insert into columns of image type in the sql table? image columns can take up to 2^31 - 1 bytes while varbinary can take only 8000 bytes, which may not be sufficient for images.
That's why there is the very usesful MAX keyword..
Check out http://sqlservergems.blogspot.com/2006/02/using-max-in-varchar-varbinary-and.html
If you are dealing with ASP.NET applications, a convenient way will be to store the images in a folder and then store the link to the image in the database table. That way, you increase the performance of your application (and storage as well).
However, if you need to store images into the database, you will need to convert your image to a byte array before storing it into the table.
I'm curious though. How are you going to retrieve the image and display it back to the web page?
Firedancer: If you are dealing with ASP.NET applications, a convenient way will be to store the images in a folder and then store the link to the image in the database table. That way, you increase the performance of your application (and storage as well).
I certainly agree that storing images in a folder, and storing the link to the image in the table is a good idea. In fact, for the past ASP.NET applications that I have developed, this is my default implementation.
In recent years, there has been much thots by different camps on letting the database manage all contents (image, sound, etc), and not just meta-data. (same argument on why WinFS should be like a file-system with a relational feel).
Ya. Thanks for the reply.
I will look at the links later, coz I am still at home. Plan to go to office later.
Hmm... the reason why I stick to storing image to the database coz of 3 reasons:
a) it is a Proof of Concept demo app. So I don't want to have troubles copying the webserver images later to the deployed machine (just in case, I forgot to copy that folder).
b) Replication issues. As i understand, replication only can copy database not your webserver folders (say images folder).
c) My colleague had developed reporting services that would read images directly from my database. She had yet to find out a way to read from "~/images/" + the filename of the image. So I don't bother to do that :) coz the dateline was near.
Maybe what I did was wrong. Coz I stored the image filename not the whole link.
Thanks anyway.
I had posted my findings here
http://community.sgdotnet.org/blogs/chuawenching/archive/2006/04/02/25584.aspx
:)