0

Hi Experts
I m trying to retry images from database. My code is as below

DataTable tab = obj.createtable("Select pics from picto");//obj is the class in which createtable(string query) is function which returns datatable according to query

            byte[] ImgByte = (byte[])tab.Rows[0][0];
            FileStream fs = new FileStream("test.GIF", FileMode.Create);
            fs.Write(ImgByte, 0, ImgByte.Length);
            fs.Close();
            fs = null;
            pictureBox2.Image = Image.FromFile("test.GIF");

the last line give "out of memory " error.
Plz help me

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by __avd
0

I have tried another way.

DataTable tab = obj.createtable("Select pics from picto where id=1");
//obj is a class in which createtable(string query) is a function which returns datatable of query
            byte[] ImgByte = (byte[])tab.Rows[0][0];
            MemoryStream fs = new MemoryStream(ImgByte);
            fs.Write(ImgByte, 0, ImgByte.Length);
            MessageBox.Show(ImgByte.Length.ToString());
            Bitmap bm = new Bitmap(fs);
            pictureBox2.Image = bm;

this gives "Parameter no valid " error
plz help me.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.