uploading/retrieving photo from form to sql server database

By sosabou ·
How do i upload a photograph(passport)photo from a form to my database (sQL Server 2005)

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Well first step

by Tony Hopkinson In reply to uploading/retrieving phot ...

is to get the Image, bitmap, png, into a stream.
Then you get that into an array of bytes

Then you create SQLCommand object and set query to something like

'Update MyPhotos Set Photo = @Photo Where PersonID = @Person'

That gives you a parameterised query

Then you create and add the parameters

SQLParameter param = new SqlParameter("@Photo", SqlDbType.Image);
param.Value = ImageAsByteArray

Set up the where parameter
and execute the command.

Bit c# ish, because I don't use, but the .Net stuff is the same.

PIA isn't it.

Related Discussions

Related Forums