private void button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=SYS12;Initial Catalog=Teju;Integrated Security=True");
SqlCommand cmd = new SqlCommand("Select Picture from tblImgData where id= " + listBox1.SelectedValue + " ", con);
con.Open();
byte[] byteImg = (byte[])cmd.ExecuteScalar();
string strfn = Convert.ToString(DateTime.Now.ToFileTime());
FileStream fs = new FileStream(strfn, FileMode.CreateNew, FileAccess.Write);
fs.Write(byteImg, 0, byteImg.Length-1);
fs.Flush();
fs.Close();
pictureBox1.Image = Image.FromFile(strfn);
}
Этот код показывает ошибку как "Out of memory
." Что я могу делать не так, или как я могу отладить и решить эту проблему? Спасибо!