467,879 Members | 1,263 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,879 developers. It's quick & easy.

Saving an image to SQL Server's image datatype

I am using ASP.NET 2.0, and need to know how to save and use an image that
is stored in an SQL Server image datatype. How can I do this using ASP.NET?
Thanks.
Jul 17 '08 #1
  • viewed: 7123
Share:
10 Replies
On Jul 17, 11:38*am, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:
I am using ASP.NET 2.0, and need to know how to save and use an image that
is stored in an SQL Server image datatype. How can I do this using ASP.NET?
Thanks.
google is your friend...

http://www.codeproject.com/KB/web-image/PicManager.aspx
http://aspalliance.com/articleViewer.aspx?aId=138
http://bytes.com/forum/thread287108.html

HTH,
Stu
Jul 17 '08 #2
Or search.live.com. :-)

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"Stuart Ainsworth" <st**************@gmail.comwrote in message
news:09**********************************@34g2000h sh.googlegroups.com...
On Jul 17, 11:38 am, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:
I am using ASP.NET 2.0, and need to know how to save and use an image that
is stored in an SQL Server image datatype. How can I do this using
ASP.NET?
Thanks.
google is your friend...

http://www.codeproject.com/KB/web-image/PicManager.aspx
http://aspalliance.com/articleViewer.aspx?aId=138
http://bytes.com/forum/thread287108.html

HTH,
Stu
Jul 17 '08 #3
A well-kept secret :-)

"TheSQLGuru" wrote:
Or search.live.com. :-)

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"Stuart Ainsworth" <st**************@gmail.comwrote in message
news:09**********************************@34g2000h sh.googlegroups.com...
On Jul 17, 11:38 am, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:
I am using ASP.NET 2.0, and need to know how to save and use an image that
is stored in an SQL Server image datatype. How can I do this using
ASP.NET?
Thanks.

google is your friend...

http://www.codeproject.com/KB/web-image/PicManager.aspx
http://aspalliance.com/articleViewer.aspx?aId=138
http://bytes.com/forum/thread287108.html

HTH,
Stu
Jul 18 '08 #4
On Jul 18, 8:19*am, Linchi Shea <LinchiS...@discussions.microsoft.com>
wrote:
A well-kept secret :-)

"TheSQLGuru" wrote:
Or search.live.com. *:-)
--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"Stuart Ainsworth" <stuart.ainswo...@gmail.comwrote in message
news:09**********************************@34g2000h sh.googlegroups.com...
On Jul 17, 11:38 am, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:
I am using ASP.NET 2.0, and need to know how to save and use an imagethat
is stored in an SQL Server image datatype. How can I do this using
ASP.NET?
Thanks.
google is your friend...
http://www.codeproject.com/KB/web-image/PicManager.aspx
http://aspalliance.com/articleViewer.aspx?aId=138
http://bytes.com/forum/thread287108.html
HTH,
Stu- Hide quoted text -

- Show quoted text -
Hi,
Saving image in database is not a good idea, this activity create
unnessary bulky database.
Ok.. If you want to save image in the database, you can use varbinary
datatype insteda of image, microsoft will remove image datatype in
there earlier version.

Rahul
Jul 18 '08 #5
I've even heard of yahoo.com, but that might be a rumor.
ML

---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com/
Jul 18 '08 #6
Saving image in database is not a good idea, this activity create
unnessary bulky database.
It depends. If you have a large number of small images, you may be better
off storing them in the database. If you have a relatively small number of
large images, it may be better to keep them in the filesytem. If you want to
stream from these images, keep them outside of the database.

Linchi

"Rahul" wrote:
On Jul 18, 8:19 am, Linchi Shea <LinchiS...@discussions.microsoft.com>
wrote:
A well-kept secret :-)

"TheSQLGuru" wrote:
Or search.live.com. :-)
--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"Stuart Ainsworth" <stuart.ainswo...@gmail.comwrote in message
>news:09**********************************@34g2000 hsh.googlegroups.com...
On Jul 17, 11:38 am, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:
I am using ASP.NET 2.0, and need to know how to save and use an image that
is stored in an SQL Server image datatype. How can I do this using
ASP.NET?
Thanks.
google is your friend...
>http://www.codeproject.com/KB/web-image/PicManager.aspx
>http://aspalliance.com/articleViewer.aspx?aId=138
>http://bytes.com/forum/thread287108.html
HTH,
Stu- Hide quoted text -
- Show quoted text -

Hi,
Saving image in database is not a good idea, this activity create
unnessary bulky database.
Ok.. If you want to save image in the database, you can use varbinary
datatype insteda of image, microsoft will remove image datatype in
there earlier version.

Rahul
Jul 18 '08 #7
OK, but regardless of my choice, I need to know what my code should look
like to get them into and out of the DB. I have used the FileUpload control
before to upload a file to the file system, but I have never put an image
(or any other type of file) into a database. If you know of any examples, it
would be extremely helpful. Thanks.

Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Linchi Shea" <Li********@discussions.microsoft.comwrote in message
news:46**********************************@microsof t.com...
>Saving image in database is not a good idea, this activity create
unnessary bulky database.

It depends. If you have a large number of small images, you may be better
off storing them in the database. If you have a relatively small number of
large images, it may be better to keep them in the filesytem. If you want
to
stream from these images, keep them outside of the database.

Linchi

"Rahul" wrote:
>On Jul 18, 8:19 am, Linchi Shea <LinchiS...@discussions.microsoft.com>
wrote:
A well-kept secret :-)

"TheSQLGuru" wrote:
Or search.live.com. :-)

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net

"Stuart Ainsworth" <stuart.ainswo...@gmail.comwrote in message
news:09**********************************@34g2000 hsh.googlegroups.com...
On Jul 17, 11:38 am, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:
I am using ASP.NET 2.0, and need to know how to save and use an
image that
is stored in an SQL Server image datatype. How can I do this using
ASP.NET?
Thanks.

google is your friend...

http://www.codeproject.com/KB/web-image/PicManager.aspx
http://aspalliance.com/articleViewer.aspx?aId=138
http://bytes.com/forum/thread287108.html

HTH,
Stu- Hide quoted text -

- Show quoted text -

Hi,
Saving image in database is not a good idea, this activity create
unnessary bulky database.
Ok.. If you want to save image in the database, you can use varbinary
datatype insteda of image, microsoft will remove image datatype in
there earlier version.

Rahul

Jul 24 '08 #8
like to get them into and out of the DB. I have used the FileUpload control
before to upload a file to the file system, but I have never put an image
(or any other type of file) into a database. If you know of any examples, it
would be extremely helpful.
WHICH file upload control? Some of them have a built-in SaveToDatabase-type
method. This is a component I used to use in "Classic ASP" development,
which had this functionality built in:

http://www.aspupload.com/manual_db.html

If you are using .NET then Google yields some results fairly quickly:

http://www.eggheadcafe.com/articles/20030624.asp

http://www.codeproject.com/KB/databa...nDataBase.aspx

http://blog.codebeach.com/2008/02/ho...ql-server.html

(What does this have to do with fulltext / clients?)

Jul 24 '08 #9
Nathan Sokalski laid this down on his screen :
OK, but regardless of my choice, I need to know what my code should look like
to get them into and out of the DB. I have used the FileUpload control before
to upload a file to the file system, but I have never put an image (or any
other type of file) into a database. If you know of any examples, it would be
extremely helpful. Thanks.
I use a store procedure with a parameter of type "image". Inside that
procedure you can use that variable to insert into the table.

When calling that stored procedure from the .Net code, I use parameters
to supply the data. The image-type parameter is then filled with the
byte[] containing that file.

Hans Kesting
Jul 25 '08 #10
Hey Nathan,

An article on Large Object Storage in a Database or a Filesystem
http://research.microsoft.com/resear...MSR-TR-2006-45
If you want to know how I do it:

I use and Image.aspx page and stream the image to that page then in and
other page i use and image controle and set the image.aspx page as image
path.
To get the connection I use linq in the example I make the query with linq
but that is not fast with large tables so you’re better off using stored
procedures with linq.

example:
The page with the image control
imgImageControl.ImageUrl = "Image.aspx?Id=2";
The image.aspx page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Try
Dim objNV As NameValueCollection
Dim pic() As Byte = Nothing
Dim strID As String = ""
objNV = Request.QueryString()
If Not objNV.Count = 0 Then
strID = objNV.Item("ID")
Else
pic = Session("Id")
If pic Is Nothing Then
strID = User.Identity.Name.ToString()
End If
End If
If Not strID = "" Then
Dim db As New
myDB(ConfigurationManager.ConnectionStrings("sql1" ).ConnectionString)
Dim Updateprofiel = (From p In db.Profiels Where p.Prof_ID =
strID Select p.Foto).ToList()(0)
If Not Updateprofiel Is Nothing Then
pic = Updateprofiel.ToArray()
End If
db.Connection.Close()
End If
If Not pic Is Nothing Then
Response.ContentType = "image/jpeg"
Response.OutputStream.Write(pic, 0, pic.Length)
End If
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Critical, "Big error run
away!!!!!")
End Try

End Sub

steve
"Nathan Sokalski" wrote:
I am using ASP.NET 2.0, and need to know how to save and use an image that
is stored in an SQL Server image datatype. How can I do this using ASP.NET?
Thanks.
Aug 3 '08 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Laszlo Zsolt Nagy | last post: by
2 posts views Thread by Robson Carvalho Machado | last post: by
6 posts views Thread by Suraj Joneja | last post: by
2 posts views Thread by =?Utf-8?B?UmludSBHb3BhbGFrcmlzaG5hIFBpbGxhaQ==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.