storing and retriveal of a image
how can i store a image and retrieve that image in sql2003 in c#.Net code
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
ruchir srivastavaPosted Feb 13, 2008, 12:49 AM
Tal GiladiPosted Feb 12, 2008, 3:08 PM
for storing you need to use parameterized sql command - meaning you'll add the image bytes as an sql parameter (assuming you have a table with a column defined as image):
SqlCommand com = new SqlCommand("insert into mytable (myimage) values(@myimage");
com.Parameters.Add(new SqlParameter("@myimage", myImageBytes));
for retrieving, well, just get the byte array from the database and use the Bitmap class to read bytes to image again, or just send the bytes with the Page Response Binary Write