把已经存入数据库的图片读取出来

xindeyitian8888 2009-08-02 09:05:23
SqlConnection sqlcon = new SqlConnection(" Data Source=PC-20090625HIOS \\SQLEXPRESS;Initial Catalog=student;Integrated Security=True");
sqlcon.Open();
string str = "select uphoto from user2 where uname='"+textBox1.Text.Trim()+"'";
SqlCommand cmd = new SqlCommand(str, sqlcon);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
pictureBox2.Image =(Image)dr["uphoto"];
}
else
{
MessageBox.Show("121");
}
这段代码错在哪里呢?我是想从数据库里把图片读取出来

我的数据库里面已经有把图片添加进去了
...全文
89 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
CopperBell 2009-08-07
  • 打赏
  • 举报
回复
存的是什么?URL?说清楚点
代码是放在哪里?若你的textbox.Text值为空怎么处理?若查找不到怎么处理?
flyhua1010 2009-08-03
  • 打赏
  • 举报
回复
帮顶了。。。。。。。。。。。。。。。。。。

6,850

社区成员

发帖
与我相关
我的任务
社区描述
Windows 2016/2012/2008/2003/2000/NT
社区管理员
  • Windows Server社区
  • qishine
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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