Question Locked

uploading/retrieving photo from vb.net form to sql server database

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How do i upload a photograph(passport)photo from a vb.net form to my database (sQL Server 2005)

2 replies

by tony hopkinson

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);
command.Parameters.Add(param);
param.Value = ImageAsByteArray

Set up the where parameter
and execute the command.

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

PIA isn't it.

This discussion is closed to new replies.