Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Storing Images/Image paths

Author  Topic 

caa5042
Starting Member

6 Posts

Posted - 2011-09-18 : 13:17:55
Guys are you familiar with the filestream storage system?
I have enabled it on my database and created a column in my table called 'Images' which has the datatype varbinary(max)

What is the next step??????? how do i store images in the column? I have looked everywhere online but all the info is extremely vague

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-18 : 13:22:55
see

http://coolthingoftheday.blogspot.com/2008/03/sql-server-2008-filestream-writing-file.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

caa5042
Starting Member

6 Posts

Posted - 2011-09-18 : 13:28:16
i find that very hard to comprehend....i didnt even know i needed to use C#...

Maybe i shouldnt be using filestream storage. None of my images are bigger than 1MB and its a fairly small database. WHat method should i use to store images?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-09-18 : 13:30:41
Do you have some reason not to store just the path / filename in the database? (and then store the images physically on the disk)
Go to Top of Page

caa5042
Starting Member

6 Posts

Posted - 2011-09-18 : 13:32:52
how would i go about doing that? would i have to enable filestream storage for that? or do i just store the path in a varchar column?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-09-18 : 13:38:53
Just store a Path / filename in a varchar column.

Then in your application you would "get" the image from that location. If you are making an HTML page then you can just do something like:

"<img src='" & MyPathColumn & MyFileNameColumn & "' height=" & MyHeightColumn & "px width=" & MyWidthColumn & "px>"

which will generate something like:


<img src='x;/MyPath/MyImage/.jpg' height=100px width=100px>

Go to Top of Page

caa5042
Starting Member

6 Posts

Posted - 2011-09-18 : 14:02:58
its an asp.net website. Its pretty much a shopping website so i want to display product info(name description,color) and the photos. I will be using the gridview control to display this info. Is it possible to place that html img tag code within the gridview control code?
Go to Top of Page

caa5042
Starting Member

6 Posts

Posted - 2011-09-18 : 14:41:26
Also, can i store the actual images in my asp.net website folder?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-09-18 : 17:38:46
Dunno how it works in ASP.NET Grid, but we build eCommerce sites and that's exactly how we do it - Path / Filename in the database, Image on the server's disk. Performs much faster, for us, than storing the image in the database, and also lots of other benefits of having the images separate from the database
Go to Top of Page

alexylee
Starting Member

14 Posts

Posted - 2011-09-19 : 23:20:23
Yes, you can save image files in ASP.NET website folder.
For small image files, storing to DB might be good choice.
For large image files, storing to FileStream can be benefical.

Article for "How to use FILESTREAM" :
[url]http://sqlmgmt.com/ProductDetail.aspx?Id=114[/url]
Go to Top of Page
   

- Advertisement -