Solved

How do I save images and documents into SQL Server 2008?

Posted on 2009-05-07
15
1,166 Views
Last Modified: 2012-05-06
I want to save images and documents into SQL Server 2008 with Visual Studio .NET 2008.
0
Comment
Question by:ReaL10
  • 7
  • 4
  • 2
  • +2
15 Comments
 
LVL 39

Accepted Solution

by:
abel earned 200 total points
ID: 24323185
There are basically two ways: one is storing the images/docs locally in a file system and putting the location and meta information in SQL Server the normal way, the other is storing the entire information inside SQL Server.

Guessing on the second option, here's a how-to: http://aspalliance.com/articleViewer.aspx?aId=138&pId=
0
 
LVL 7

Assisted Solution

by:thiyaguk
thiyaguk earned 200 total points
ID: 24323247
Yes, first option doesn't store the data in sqlserver .
For the Second one ,Please refer this also.




http://www.codeproject.com/KB/database/ImageSaveInDataBase.aspx
0
 

Author Comment

by:ReaL10
ID: 24323282
I see, but it's possible to save the entire document/image into SQL like MySQL?
0
 
LVL 7

Expert Comment

by:thiyaguk
ID: 24323301
Ofcourse. Any Binary data can be saved (The above link just does explain how to store image.)

http://www.codeproject.com/KB/database/ImageSaveInDataBase.aspx
You can save other file tyype to (same way)
0
 

Author Comment

by:ReaL10
ID: 24323345
Ok, I understand that save documents is equal like to save images?
0
 
LVL 39

Expert Comment

by:abel
ID: 24323347
> I see, but it's possible to save the entire document/image into SQL like MySQL?

well, that's precisely what my link shows you... This part is what you are after at that link (note the use of SqlDbType.Image, this does not mean 'picture' but means a bunch of bytes):

Dim prmPersonImage As New SqlParameter("@PersonImage", SqlDbType.Image)prmPersonImage.Value = ImageContentmyCommand.Parameters.Add(prmPersonImage)
0
 
LVL 39

Expert Comment

by:abel
ID: 24323350
> Ok, I understand that save documents is equal like to save images?

indeed. In fact, this way you can save any type of binary data.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 39

Expert Comment

by:abel
ID: 24323355
PS: in the code snippet above ImageContent is a byte array. See mine or thiyaguk links for how to do the whole process: from picture/doc to byte array to storage.
0
 

Author Comment

by:ReaL10
ID: 24323366
Ok, thanks.
0
 
LVL 39

Expert Comment

by:abel
ID: 24323380
welcome :)
0
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 50 total points
ID: 24324568
SQL 2008 has a new feature exactly to do that. Read about FileStream in BOL.
0
 

Assisted Solution

by:praveenkumar_3i
praveenkumar_3i earned 50 total points
ID: 24334085
Create a blob field into a table.
Insert the blob object with the file/image stream.

0
 
LVL 39

Expert Comment

by:abel
ID: 24334302
Just out of curiosity, but are there still problems rising? You last comment was a "thanks", but perhaps I mistakenly understood that as "everything works" ...
0
 

Author Comment

by:ReaL10
ID: 24334349
No, I said thanks for the possible solutions, but still I have not tried.
0
 
LVL 39

Expert Comment

by:abel
ID: 24334366
ok, np. Take your time :)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now