.net 从数据库到Windows窗体的图像
此代码将错误显示为“.net 从数据库到Windows窗体的图像,.net,sql-server,winforms,.net,Sql Server,Winforms,此代码将错误显示为“内存不足”“我可能做错了什么,或者如何调试和解决此问题?谢谢 不处理你的物品也无济于事。你可以用积木或垃圾清理。不处理你的物品也无济于事。您可以使用块或a进行清理。使用System.Drawing.Image类保存文件,然后直接将此图像分配给图片框 选中此项: private void button2_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Sour
内存不足”
“我可能做错了什么,或者如何调试和解决此问题?谢谢 不处理你的物品也无济于事。你可以用积木或垃圾清理。不处理你的物品也无济于事。您可以使用块或a进行清理。使用System.Drawing.Image类保存文件,然后直接将此图像分配给图片框
选中此项:
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);
}
使用System.Drawing.Image类保存文件,然后直接将此图像指定给图片框 选中此项:
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);
}