tags:

views:

138

answers:

2

I have this:

Create Proc CrearNuevoImagen
    @imagen image  
AS

INSERT INTO 
    Imagenes(imagen)

VALUES(
    @imagen
    )

I see that @imagen is of type 'image'.

My question is save that I have an .jpg image, on my front-end (my asp.net website code), how could I convert the .jpg image to fit into the 'image'-type column? Or does the SQL Server automatically do this for me?

+3  A: 

Save your image object to a MemoryStream. Then you can take the byte array out of the memory stream and pass that to SQL Server to save it in your "image" or "varbinary" column.

David
So, all I have to do is convert the "Image" to a "byte array" and the SQL will accept that into the 'image'-type column?
Sergio Tapia
Yes, and you'll use the GetBytes() method to read the data out with your SqlDataReader.
David
+1  A: 

The image column type is just a binary container; SQL Server doesn't interpret or modify the data you store there at all.

See http://www.informit.com/articles/article.aspx?p=377078

David Lively