To handle images, you need to use the MemoryStream class. Here is a
few code snippet for you to work on.
We will assume that we are accessing an image from a database and
saving this image as a *.jpg file in your local directory. Substitute
your code against mine:


OleDbDataReader reader = null;
...
string myquery = "SELECT IMAGEFIELD FROM TABLEFOO";

OleDbCommand cmd = new OleDbCommand(myquery, oleconn);
...
reader = cmd.ExecuteReader();
...
byte[] blobField = (byte[]) reader["MYIMAGEFIELD1"];
...
MemoryStream msSomeImage = new MemoryStream(blob_Field);
Image imgImage = Image.FromStream(msSomeImage);
imgImage.Save(@ATargetPath + ".jpg");


Hope this helps.



Benj






On Aug 18, 1:10 pm, gagandeep sharma <[email protected]> wrote:
> actually sir, in my webform i've a file upload web control, when some user
> attach any kind of document with a webform, this attachment stored in byte
> format in sql server 2000 db---
> the code i used is like below:-
>
> BtnUpload.PostedFile.InputStream.Read(imgbytes, 0, imgbytes.Length)
> but now i facing a problem, that how to read back the attachment into format
>
> for example if the user attach a image file-- this image stored in db in
> byte format
> and now how i read back it into original  format---
>
> thats it
> if u know this sir, then pls help me
> thanks
>
>
>
> On Tue, Aug 18, 2009 at 7:24 AM, Benj Nunez <[email protected]> wrote:
>
> > Might help if you be more specific.
>
> > Regards,
>
> > Benj
>
> > On Aug 17, 8:36 pm, gagandeep sharma <[email protected]> wrote:
> > > sir how to convert binary data stored in database  back it into original
> > > format
>
> > > --
> > > GO and LEAD from Whereever You are.
> > > Think Big and Think Fast.
>
> --
> GO and LEAD from Whereever You are.
> Think Big and Think Fast.

Reply via email to