我如何从数据库检索图像到当前窗体的图片框 [英] how can i retrieve image from database to picturebox of current form
本文介绍了我如何从数据库检索图像到当前窗体的图片框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码中的路径仅适用于特定图像,我该如何检索学生详细信息的不同字段?
不同图像的一般路径是什么...
The path in below code for only a particular image,how can i retrieve for different fields on students details ?
what is the general path for different images...
imgByte = (Byte[])dr[15];
if (imgByte.Length == 0)
{
pictureBox1.Image = Image.FromFile("C:\\Documents and Settings\\Administrator\\My Documents\\My Pictures\\image.jpg");
}
else
{
MemoryStream ms = new MemoryStream((Byte[])dr[15]);
pictureBox1.Image = Image.FromStream(ms);
}
推荐答案
从数据库中读取值后,将其存储在文件中.
使用 File.WriteAllBytes(Byte,FileName)将BYTE存储在文件中.然后在pictureBox中显示它
after you have read values from database store them in file.
use File.WriteAllBytes(Byte,FileName) to store BYTEs in file. and then show it in pictureBox
谢谢..
但是我收到错误参数无效..我该怎么办... n路径
Image.FromFile("C:\\ Documents and Settings \\ Administrator \\ My Documents \\ My Pictures \\ image.jpg");
必须更改...
Thank u..
But i am getting error parameter not valid..what can i do...n the path
Image.FromFile("C:\\Documents and Settings\\Administrator\\My Documents\\My Pictures\\image.jpg");
must be changed...
这篇关于我如何从数据库检索图像到当前窗体的图片框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文