【发布时间】:2012-03-16 10:01:39
【问题描述】:
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”。我可能做错了什么,或者我该如何调试和解决这个问题?谢谢!
【问题讨论】:
标签: .net sql-server winforms