How to store image in MSSQL Server using C#?

9 views
Skip to first unread message

vijaya kumara.N

unread,
Nov 20, 2008, 3:36:42 PM11/20/08
to DotNetDe...@googlegroups.com

Hi,

How to store image in SQL Server   and retrieve uisng C#.

Please help me.

Thanking u.

--
Regards,
vijay

Joe Enos

unread,
Nov 20, 2008, 10:26:43 PM11/20/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
I'm sure you can find hundreds of samples online of this, but
basically, your .NET datatype should be a byte array, and I believe
your SQL Server data type should be an IMAGE (SQL 2000) or a VARBINARY
(MAX) (SQL 2005+). Once you get this going, it's not all that
different than any other data type.

sn@gShadow

unread,
Nov 21, 2008, 3:47:52 AM11/21/08
to DotNetDe...@googlegroups.com
find this keyword in your MSDN:
"Chunking BLOB Updates (ADO.NET)"


hopefully, it will be helpful

B'Rgds
--
一日不见如隔百秋

It's not what you can get but what you can give that makes you a rich person

Brandon Betances

unread,
Nov 21, 2008, 1:02:18 PM11/21/08
to DotNetDe...@googlegroups.com
better off uploading the image to a folder and referencing the location in the DB. storing a DB takes ALOT of room up and slows you down considerable. I think my homie Stephen will agree with me here.

Stephen Russell

unread,
Nov 21, 2008, 1:11:11 PM11/21/08
to DotNetDe...@googlegroups.com

Using the db for storage is a Catch22 operation. 

 

You get backups, as well as the ability to replicate the db across data centers.

 

You get a rather large db depending on the volume of transactions and the size of the images. 

 

YMMV.

 

…………………………………………………………………

Stephen Russell –

Senior Visual Studio Developer, DBA

 

Memphis, TN

901.246-0159

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.175 / Virus Database: 270.9.9/1802 - Release Date: 11/21/2008 9:37 AM

Joe Enos

unread,
Nov 21, 2008, 1:36:52 PM11/21/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Agreed - just depends on your situation - whether you're storing just
a couple of small gifs or a bunch of large photographs, whether you
have a small one-server operation or a large server farm with load
balancers and proxy servers and mega security, what you're actually
doing with those images, etc.

On Nov 21, 11:11 am, "Stephen Russell" <sruss...@lotmate.com> wrote:
> Using the db for storage is a Catch22 operation.
>
> You get backups, as well as the ability to replicate the db across data
> centers.
>
> You get a rather large db depending on the volume of transactions and the
> size of the images.
>
> YMMV.
>
> ...........................................................................
>
> Stephen Russell -
>
> Senior Visual Studio Developer, DBA
>
> Memphis, TN
>
> 901.246-0159
>
> From: DotNetDe...@googlegroups.com
> [mailto:DotNetDe...@googlegroups.com] On Behalf Of Brandon Betances
> Sent: Friday, November 21, 2008 12:02 PM
> To: DotNetDe...@googlegroups.com
> Subject: [DotNetDevelopment] Re: How to store image in MSSQL Server using
> C#?
>
> better off uploading the image to a folder and referencing the location in
> the DB. storing a DB takes ALOT of room up and slows you down considerable.
> I think my homie Stephen will agree with me here.
>
> On Fri, Nov 21, 2008 at 3:47 AM, sn@gShadow <the....@gmail.com> wrote:
>
> find this keyword in your MSDN:
> "Chunking BLOB Updates (ADO.NET)"
>
> hopefully, it will be helpful
>
> B'Rgds
>
> On Fri, Nov 21, 2008 at 10:26 AM, Joe Enos <j...@jtenos.com> wrote:
>
> I'm sure you can find hundreds of samples online of this, but
> basically, your .NET datatype should be a byte array, and I believe
> your SQL Server data type should be an IMAGE (SQL 2000) or a VARBINARY
> (MAX) (SQL 2005+). Once you get this going, it's not all that
> different than any other data type.
>
> On Nov 20, 1:36 pm, "vijaya kumara.N" <vijayv...@gmail.com> wrote:
>
> > Hi,
>
> > How to store image in SQL Server and retrieve uisng C#.
>
> > Please help me.
>
> > Thanking u.
>
> > --
> > Regards,
> > vijay
>
> --
> 一日不见如隔百秋
>
> It's not what you can get but what you can give that makes you a rich person
>
> No virus found in this incoming message.
> Checked by AVG -http://www.avg.com

jgarra

unread,
Nov 21, 2008, 1:42:06 PM11/21/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
You're definitely better off NOT storing images in SQL Server, esp. if
you're going to have a lot. Better to store an encrypted path or
something bt to store the entire binary in a table is just going to
kill your performance.
Reply all
Reply to author
Forward
0 new messages