Solved

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

Posted on 2009-05-07
15
1,171 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 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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

726 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