可行之法:
OleDbCommand cmd = new OleDbCommand("SELECT ItemImage,ItemName,ItemType FROM Item", cn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Item");Byte[] byteBLOBData = new Byte[0];
byteBLOBData = (Byte[])(ds.Tables["Item"].Rows[c - 1]["ItemImage"]);
MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
pictureBox1.Image = Image.FromStream(stmBLOBData);暂时不能运行的办法:
myReader = cls.Reader("select * from Item")byte[] byteIco =(byte[])(myReader["ItemImage"]);
Stream stmImage = new MemoryStream(byteIco);
PictureBox ButtonIco = new PictureBox();
pictureBox1.Image = Image.FromStream(stmImage );第二种方法能读出其它内容,但图片显示为一片白色,为什么,在线等
OleDbCommand cmd = new OleDbCommand("SELECT ItemImage,ItemName,ItemType FROM Item", cn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Item");Byte[] byteBLOBData = new Byte[0];
byteBLOBData = (Byte[])(ds.Tables["Item"].Rows[c - 1]["ItemImage"]);
MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
pictureBox1.Image = Image.FromStream(stmBLOBData);暂时不能运行的办法:
myReader = cls.Reader("select * from Item")byte[] byteIco =(byte[])(myReader["ItemImage"]);
Stream stmImage = new MemoryStream(byteIco);
PictureBox ButtonIco = new PictureBox();
pictureBox1.Image = Image.FromStream(stmImage );第二种方法能读出其它内容,但图片显示为一片白色,为什么,在线等
解决方案 »
- 请教个打印问题,打印表格的
- Soap 序列化程序不支持序列化一般类型: System.Collections.Generic.List`1[System.Object]。
- vs2008 web开发debug后无法打开localhost
- 急!怎么老是出现"'dbo'附近有语法错误"?
- 问一个owc11的问题(因为不知道去哪个版问,而我又是用C#的,所以冒昧跑来问一下)
- 这个复合窗体怎么做啊
- 请问高手关于C#的UAC问题(图标上盾牌显示的问题)
- 操作活动目录的问题!!!!!!
- 安装程序制作
- 引用了第三方类库DLL,有它的源码,如何将它的源码加入到调试路径中
- 数据库问题 Adapter.Update总是返回0 不能更新
- 下载网络文件到本地出错,哪位高手可以帮忙看看啊
CommandBehavior 枚举 SequentialAccessSequentialAccess 提供一种方法,以便 DataReader 处理包含带有大二进制值的列的行。SequentialAccess 不是加载整行,而是使 DataReader 将数据作为流来加载。然后可以使用 GetBytes 或 GetChars 方法来指定开始读取操作的字节位置以及正在返回的数据的有限的缓冲区大小。
当指定 SequentialAccess 时,尽管无需读取每个列,但是需要按照列的返回顺序读取它们。一旦已经读过返回的数据流中某个位置的内容,就不能再从 DataReader 中读取该位置或该位置之前的数据。当使用 OleDbDataReader 时,可重新读取当前列的值,直到读过它。当使用 SqlDataReader 时,一次只能读取一个列值。
sr.GetBytes();
//加上这句
myReader.read()
.....
....
...
..
.
Label LabelButton = new Label();
LabelButton.Image = myImages.Images[ZCNum * 2];
LabelButton.Name = "lableButton" + ZCNum.ToString();
LabelButton.Size = new Size(112, 25);
LabelButton.Text = myReader["ItemName"].ToString();
LabelButton.Visible = true;
LabelButton.Location = new Point(0, ZCTop);
LabelButton.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
panelZC.Controls.Add(LabelButton)
//第二段,在lable上添加一个小的点缀图
Byte[] byteIco = new Byte[0];
byteIco = (Byte[])(myReader["ItemImage"]);
MemoryStream stmIco = new MemoryStream(byteIco);
PictureBox ButtonIco = new PictureBox();
ButtonIco.Image = Image.FromStream(stmIco);
ButtonIco.Location = new Point(20,ZCTop );
ButtonIco.Visible = true;
ButtonIco.Size = new Size(20, 20);
panelZC.Controls.Add(ButtonIco); ZCNum++;
ZCTop += LabelButton.Height + 1;
本段代码中,无论注释掉第一段或第二段都能显示出相应图标,带两段一起运行时,第二段的图片显示不出来(ButtonIco显示为一片白色,而不是我想要的图),请问为什么?