pictureBox1.Image = Image.FromStream(ms)出错(参数无效)
string sql = "select cid,img from PicTable order by cid";SqlCommand cmd = new SqlCommand(sql, con);
SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd);
DataSet dataSet = new DataSet();
dataAdapter.Fill( dataSet , "BLOBTEST");
int c = dataSet.Tables["BLOBTEST"].Rows.Count;
try
{
if (c > 0)
{
byte[] mybyte = new byte[0];
mybyte = (Byte[])(dataSet.Tables["BLOBTEST"].Rows[c - 1]["img"]);
MemoryStream ms = new MemoryStream(mybyte);//此处没有问题。可以读到mybyte数组
pictureBox1.Image = Image.FromStream(ms);
}
con.Close();
}
好无奈,好多地方看到都是这样写的,不清楚为什么会出错。
[ 本帖最后由 jack_xu2046 于 2010-10-1 22:51 编辑 ]