473,499 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7394
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
5516
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
8459
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
2692
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
3614
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
2207
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
2344
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
2505
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
3282
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
2704
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
1949
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
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.