[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-05-07
15
Medium Priority
?
1,184 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

830 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