473,233 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,233 software developers and data experts.

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
10 7378
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Laszlo Zsolt Nagy | last post by:
I would like to load image from a directory right into an image list. I wrote a simple library that loads the images in the directory and resizes them as needed before adding to the wx.ImageList....
2
by: Bob | last post by:
Hello: I've tried showing an image field from an MS SQL Server 2000 image field on an ASP page but All I get is this http://http://new.confectioneryhouse.com/glutenfree/about.asp I added the...
2
by: Ester | last post by:
Instead of drag and drop image button from Toolbox and name the image button id on the properties box, I would like to load image button ID from database. I created a database table that stores...
1
by: Novice | last post by:
I'm afraid I will incur the wraith of Mr. Powell on this one - but I did read his #1 FAQ and some others and I still can't figure this out. I created this little c# app. and I have a PictureBox...
3
by: RobertH | last post by:
Hello all. I have been hacking away trying to get a SQL image (jpeg) to render in a control or table row Without using the Response.BinaryWrite.... I think i might be on the verge but need a...
2
by: Robson Carvalho Machado | last post by:
Dear Friends, Does anybody knows how to use the below code with an image stored at SQL Image field? Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
6
by: Suraj Joneja | last post by:
Hi All, I've an image control on my ASP.net page. This displays an image named 'Logo.jpg' in the location '~\Images'. Another application can change this image. It can select any image and...
0
by: ProgGuru | last post by:
Hi, I have a problem in the Image storing and retrieving at SQL Server 2005, my code is: ----------------------------------------------------------------------------- for storing: Image...
2
by: =?Utf-8?B?UmludSBHb3BhbGFrcmlzaG5hIFBpbGxhaQ==?= | last post by:
Hi, I have a C# Web application , in which I need to show tiff image in an image control.The image loading is from a bitmap object and not from a file. Please advise me .... Thanks and...
6
by: hsegoy1979 | last post by:
Dear All Iam new to asp.net. I want to display image on server machine uploaded from client machine using javascript. Any Help Thankx in Advance Yogesh
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.