?
Solved

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

Posted on 2009-05-07
15
Medium Priority
?
1,178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 2
  • +2
15 Comments
 
LVL 39

Accepted Solution

by:
abel earned 800 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 800 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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
 
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 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 200 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 200 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

762 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