Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 04, 2012 04:02 AM by teguhyuliantos
Member
342 Points
474 Posts
Apr 24, 2012 01:48 PM|LINK
hi everybody
i want to save image in db which datatype should i use(image or binary[])?the best one.i also need a code example(i dont find good code).
remmeber i dont want to save address of image i just want to save image in DB.
All-Star
27330 Points
5459 Posts
MVP
Apr 24, 2012 01:53 PM|LINK
Image works fine for me :)
Apr 24, 2012 02:23 PM|LINK
44 Points
7 Posts
Apr 24, 2012 04:18 PM|LINK
I use VARBINARY(MAX), it works fine. The UPDATE TABLE code is:
SET TargetImage = (SELECT * FROM OPENROWSET(BULK N'your image path on server', SINGLE_BLOB) AS TargetImage)
Contributor
2212 Points
401 Posts
Apr 24, 2012 04:32 PM|LINK
Hi!
I will prefer you to store address of image in DB but if you don't want to store address of image file in DB then you can use image datatype.
See following URL for example:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=129
Hope this will solve your problem.
Thanks.
118619 Points
18779 Posts
Apr 26, 2012 01:36 AM|LINK
vahidarr should i use(image or binary[])?
In SQL field,I think you can use image type,For C#,use byte group——byte[]。
You can use File.ReadAllBytes to read out the whole byte group collection and set assignment to db。
Here's an example you can refer made by me to use GridView+DetailsView+Httphandler to insert a whole img into db:
http://code.msdn.microsoft.com/Uploadedit-image-in-ASPNET-b96367a9
2270 Points
659 Posts
Apr 26, 2012 01:43 AM|LINK
hi
refer this link
http://csharpektroncmssql.blogspot.com/2012/01/how-to-save-image-in-database-in-aspnet.html
Participant
1370 Points
372 Posts
May 04, 2012 04:02 AM|LINK
To save the images in db asp, please refer the link below, maybe your problem can solve.
http://www.aspnettutorials.com/tutorials/database/Save-Img-ToDB-Csharp.aspx
Regards
vahidarr
Member
342 Points
474 Posts
save image in sql
Apr 24, 2012 01:48 PM|LINK
hi everybody
i want to save image in db which datatype should i use(image or binary[])?the best one.i also need a code example(i dont find good code).
remmeber i dont want to save address of image i just want to save image in DB.
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: save image in sql
Apr 24, 2012 01:53 PM|LINK
Image works fine for me :)
Always seeking an elegant solution.
vahidarr
Member
342 Points
474 Posts
Re: save image in sql
Apr 24, 2012 02:23 PM|LINK
MayS
Member
44 Points
7 Posts
Re: save image in sql
Apr 24, 2012 04:18 PM|LINK
I use VARBINARY(MAX), it works fine. The UPDATE TABLE code is:
SET TargetImage = (SELECT * FROM OPENROWSET(BULK N'your image path on server', SINGLE_BLOB) AS TargetImage)
AccuWebHosti...
Contributor
2212 Points
401 Posts
Re: save image in sql
Apr 24, 2012 04:32 PM|LINK
Hi!
I will prefer you to store address of image in DB but if you don't want to store address of image file in DB then you can use image datatype.
See following URL for example:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=129
Hope this will solve your problem.
Thanks.
Top Windows VPS Provider
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: save image in sql
Apr 26, 2012 01:36 AM|LINK
In SQL field,I think you can use image type,For C#,use byte group——byte[]。
You can use File.ReadAllBytes to read out the whole byte group collection and set assignment to db。
Here's an example you can refer made by me to use GridView+DetailsView+Httphandler to insert a whole img into db:
http://code.msdn.microsoft.com/Uploadedit-image-in-ASPNET-b96367a9
bhaskar.mule
Contributor
2270 Points
659 Posts
Re: save image in sql
Apr 26, 2012 01:43 AM|LINK
hi
refer this link
http://csharpektroncmssql.blogspot.com/2012/01/how-to-save-image-in-database-in-aspnet.html
Site:Rare technical solutions
teguhyuliant...
Participant
1370 Points
372 Posts
Re: save image in sql
May 04, 2012 04:02 AM|LINK
To save the images in db asp, please refer the link below, maybe your problem can solve.
http://www.aspnettutorials.com/tutorials/database/Save-Img-ToDB-Csharp.aspx
Regards