C#从数据库中读取图片
下面是一些代码,可是不显示图片:stringstr=string.Format("seleteHphotofromMy_HotelwhereHname='ss'");tr...
下面是一些代码,可是不显示图片:
string str = string.Format("selete Hphoto from My_Hotel where Hname='ss'");
try
{
SqlCommand command = new SqlCommand(str, DBHelper.con);
DBHelper.con.Open();
SqlDataReader picture = command.ExecuteReader();
MemoryStream ms = new MemoryStream((byte[])picture.GetValue(0));
Bitmap but=new Bitmap(ms);
pictureBox1.Image = but;
picture.Close();
}
catch (Exception ex)
{
MessageBox.Show("错误");
}
finally
{
DBHelper.con.Close();
}
运行的时间只显示错误!请高手解答 展开
string str = string.Format("selete Hphoto from My_Hotel where Hname='ss'");
try
{
SqlCommand command = new SqlCommand(str, DBHelper.con);
DBHelper.con.Open();
SqlDataReader picture = command.ExecuteReader();
MemoryStream ms = new MemoryStream((byte[])picture.GetValue(0));
Bitmap but=new Bitmap(ms);
pictureBox1.Image = but;
picture.Close();
}
catch (Exception ex)
{
MessageBox.Show("错误");
}
finally
{
DBHelper.con.Close();
}
运行的时间只显示错误!请高手解答 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询