Upload jpg/gif to SQL Server field

  • Thread starter Thread starter Andrew Banks
  • Start date Start date
A

Andrew Banks

I've coded a page that uploads a file to a directory on the server.

I'm now thinking it would be more convenient for this project if the file
was placed in a field in my SQL Server DB.

Can anyone give me an insight on how I might go about doing this please?

Thanks,
Andrew
 
Thanks Cor,
Should have mentioned I'm working in C#

Are there any examples for this?
 
Hi Andrews,

I have copied this from a program, it is VB.net but that part is so easy to
translate that I think you can do that yourself. It is a piece of program
from which I removed a lot of things, so when you see something strange,
that is the reason. I do want to give you the basics with this and for an
image and for a thumpnail. because that last you will see you will need if
you want to get a quick show of the contents of your database. If you really
cannot translate this to C# I will do it for you.

Dim ms As New MemoryStream
Dim arrImage() As Byte
originalImage.Save(ms, ImageFormat.Jpeg)
arrImage = ms.GetBuffer
dsFototabel.Tables(0).Rows(0)("foto") = arrImage
Dim PThumbnail As Image
PThumbnail = showimage.GetThumbnailImage(66, 100, Nothing, New IntPtr)
PThumbnail.Save(ms, ImageFormat.Jpeg)
arrImage = ms.GetBuffer
dsFototabel.Tables(0).Rows(0)("thumb") = arrImage

I hope this helps?

Cor
 
Back
Top