Mysql 问题 界面上一个datagirdview 和一个pictruebox 现在我选中一行 想把里面的图片显示到piturebox 如何实现?是mysql 数据库! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 转到MySQL社区吧!语法不同。不过原理差不多。 private void BtnShow_Click(object sender, System.EventArgs e) { SqlConnection conn=new SqlConnection(ConnectString); string strSql="SELECT Photo from Picture where StudentID="1:; SqlCommand cmd=new SqlCommand(strSql,conn); conn.Open(); SqlDataReader reader=cmd.ExecuteReader(); reader.Read(); MemoryStream ms=new MemoryStream((byte[])reader["Photo"]); //创建一个内存 读取数据流,将读取的数据库的图片以二进制的byte[]流存入内存中。 reader.Close(); conn.Close(); StudentPhoto.Image=Image.FromStream(ms,true); //从刚才存储到内存的数据流中创建Image对象。 StudentPhoto.SizeMode=PictureBoxSizeMode.CenterIma;} 尼玛,到底啥是面向对象(牢骚贴) 日期 转换成 字符串,怎么样去掉 时间? 怎么做一个滚动广告,要求滚动条中的字可以从XML文件中读出 奇怪的问起!!!! 如何实现TreeView节点间的拖动?(C# WinForm) 请教关于winform开发遇到的2个问题 两个form窗体上dategridview 拖拽 不好解决的多线程问题??? 如何让对话框返回值? XML 到 Access 算法问题,求大家帮忙,TKS。 C#事物的回滚问题
private void BtnShow_Click(object sender, System.EventArgs e)
{
SqlConnection conn=new SqlConnection(ConnectString);
string strSql="SELECT Photo from Picture where StudentID="1:;
SqlCommand cmd=new SqlCommand(strSql,conn);
conn.Open();
SqlDataReader reader=cmd.ExecuteReader();
reader.Read();
MemoryStream ms=new MemoryStream((byte[])reader["Photo"]);
//创建一个内存 读取数据流,将读取的数据库的图片以二进制的byte[]流存入内存中。
reader.Close();
conn.Close();
StudentPhoto.Image=Image.FromStream(ms,true); //从刚才存储到内存的数据流中创建Image对象。
StudentPhoto.SizeMode=PictureBoxSizeMode.CenterIma;
}