pictureBox1.Image = Image.FromStream(ms)------->参数无效 [英] pictureBox1.Image =Image.FromStream(ms) -------> Parameter is not valid

查看:97
本文介绍了pictureBox1.Image = Image.FromStream(ms)------->参数无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用(SqlConnection conn =新的SqlConnection(数据源=.\\ SQLEXPRESS; AttachDbFilename = C:\\ Documents and Settings \\ meekun.poon \\ My Documents \\ Visual Studio 2008 \\ Projects \\ TrackLocation \ \ TrackLocation \\ barcodePrinter.mdf; Integrated Security = True; User Instance = True))
{


使用(SqlCommand cmd = new SqlCommand("SELECT ImageName FROM Image WHERE ImageID =" PL001",conn))
{
conn.Open();
SqlDataAdapter adpt =新的SqlDataAdapter(cmd);
DataSet dataSet =新的DataSet();
adpt.Fill(dataSet,"Image");
DataRow行;
行= dataSet.Tables [图像"].行[0];
byte [] MyImg =(byte [])Row [0];
MemoryStream ms =新的MemoryStream(MyImg);
ms.Position = 0;

pictureBox1.Image = Image.FromStream(ms); //错误

}
conn.Close();
}


*****如何解决这个问题呢???谢谢...

using (SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\meekun.poon\\My Documents\\Visual Studio 2008\\Projects\\TrackLocation\\TrackLocation\\barcodePrinter.mdf;Integrated Security=True;User Instance=True"))
{


using (SqlCommand cmd = new SqlCommand("SELECT ImageName FROM Image WHERE ImageID=''PL001''", conn))
{
conn.Open();
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
DataSet dataSet = new DataSet();
adpt.Fill(dataSet, "Image");
DataRow Row;
Row = dataSet.Tables["Image"].Rows[0];
byte[] MyImg = (byte[])Row[0];
MemoryStream ms = new MemoryStream (MyImg);
ms.Position = 0;

pictureBox1.Image =Image.FromStream(ms); //error

}
conn.Close();
}


*****how to solve this problem??? thanks...

推荐答案

尝试一下:pictureBox1.Image = new Bitmap(ms);
Try this: pictureBox1.Image = new Bitmap(ms);


这篇关于pictureBox1.Image = Image.FromStream(ms)------->参数无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆