how to insert images to db then how to bind image field.

Posted by Jayakumars under ASP.NET on 10/14/2011 | Points: 10 | Views : 1018 | Status : [Member] [MVP] | Replies : 1
Hi
I am doing image insert to db and retrieve them. I am inserted byte for images
like this

My Insert Code

int length = FupImage.PostedFile.ContentLength;
byte[] imgbyte = new byte[length];
HttpPostedFile img = FupImage.PostedFile;
img.InputStream.Read(imgbyte, 0, length);
cmd.Parameters.Add(new SqlParameter("@StdImagePath", SqlDbType.Image)).Value = imgbyte;


How to populated the image field

my code below but did not bind them plz change the code but this is not working
===========================================================

SqlCommand command = new SqlCommand("select StdImagePath from Tbl_StudentsProfile where StudentID=" + autoID +"", con);
SqlDataReader dr = command.ExecuteReader();
dr.Read();
Context.Response.BinaryWrite((Byte[])dr[0]);


Mark as Answer if its helpful to you


Responses

Posted by: Vforvijay on: 10/14/2011 [Member] Starter | Points: 25

Up
0
Down
HI.....Refer the below link.........
http://vbdotnetaddict.blogspot.com/2011/06/how-to-validate-uploaded-images-in.html

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response