Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 从数据库到Windows窗体的图像_.net_Sql Server_Winforms - Fatal编程技术网

.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);
}