提示 参数无效

chyjty 2011-06-22 08:33:23
从数据库中读取图片放入图片控件
SqlConnection conn = Class1.str();
conn.Open();
SqlDataAdapter comm = new SqlDataAdapter("select Uzhaopian from Users where Uname='" + dataGridView1.SelectedCells[1].Value.ToString() + "'", conn);
DataSet ds = new DataSet();
comm.Fill(ds);
//SqlDataReader sdr = comm.ExecuteReader();
//sdr.Read();
//byte[] bImg = (byte[])sdr["Uzhaopian"];

MemoryStream stream = new MemoryStream((byte[])ds.Tables[0].Rows[0][0]);

pictureBox1.Image = Image.FromStream(stream);
...全文
167 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
garfieldzf 2011-06-22
  • 打赏
  • 举报
回复

using(MemoryStream ms =new MemoryStream(bytes))
{
Image photo=null;
ms.Write(bytes,0,bytes.length);
photo =Image.FromStream(ms);
}
ghost5216 2011-06-22
  • 打赏
  • 举报
回复
pictureBox1.Image = Image.FromStream((Stream)stream); stream参数无效
chyjty 2011-06-22
  • 打赏
  • 举报
回复
pictureBox1.Image = Image.FromStream(stream); stream参数无效

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧