private void Button2_Click(object sender, System.EventArgs e)
    {
        connection.Open();
        SqlCommand command1 = new SqlCommand("select imgfile from myimages
where imgna...@param", connection);
        SqlParameter myparam = command1.Parameters.Add("@param",
SqlDbType.NVarChar,
30);
        myparam.Value = txtimgname.Text;
        byte[] img = (byte[])command1.ExecuteScalar();
        MemoryStream str = new MemoryStream();
        str.Write(img, 0, img.Length);
        Bitmap bit = new Bitmap(str);
        Response.ContentType = "image/jpeg";//or you can select your
imagetype from database or directly write it here
        bit.Save(Response.OutputStream, ImageFormat.Jpeg);
        connection.Close();
    }


Pratiksha























n Tue, Aug 18, 2009 at 10:40 AM, 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