المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : open an image from database



C# Programming
07-04-2009, 02:50 AM
hi...
i am saving images in a DB
when i try to open them from the database i have an error
the code:


SqlConnection con1 = new SqlConnection("DATA SOURCE = MAX_TOSHIBA ;Initial Catalog= nodule ; Integrated security = True");
SqlDataAdapter adp1 = new SqlDataAdapter();
SqlCommand com1 = new SqlCommand("SELECT the_pic FROM pic where pic_id='" + chos_pic_id.ToString() + "' and pic_no='" + chos_pic_no.ToString() + "'",con1);
adp1.SelectCommand = com1;
DataTable t__1 = new DataTable();
adp1.Fill(t__1);
byte[] by_ = (byte[])t__1.Rows[0][0];
FileStream FS1 = new FileStream("image.jpg", FileMode.Create);
FS1.Write(by_, 0, by_.Length);

FS1.Flush();
FS1.Close();

pictureBox1.Image = Image.FromFile("image.jpg");



the error appear in the last line saying "out of memory"



thanks in advance http://www.barakasoft.com/script/Forums/Images/smiley_wink.gif