大家帮忙看看这句话,怎么写啊!!?

dangdang0883 2008-03-07 04:37:07
private void SetStudentData(IDataReader idr, StudentInfo studentInfo)
{
studentInfo.Name = idr.GetString(0);
studentInfo.Sex = idr.GetBoolean(1);
studentInfo.Birthday = idr.GetDateTime(2);
studentInfo.Nation = idr.GetString(3);
studentInfo.NationPlace = idr.GetString(4);
studentInfo.Address = idr.GetString(5);
studentInfo.Image = (byte[])idr.GetValue(6);//就这句话怎么写啊
studentInfo.Memo = idr.GetString(7);
studentInfo.StudentStatus = idr.GetString(8);
}

studentInfo.image 是 byte[] 类型;
数据库中是 image 类型;
...全文
72 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiatong1981 2008-03-07
  • 打赏
  • 举报
回复


if( rdr["image字段"] != System.DbNull.Value )
{
byte[] bimage = (byte[])rdr["image字段"];
}
ericzhangbo1982111 2008-03-07
  • 打赏
  • 举报
回复
1楼的在做什么?
lake_cx 2008-03-07
  • 打赏
  • 举报
回复
studentInfo.Image = Image.FromStream(new MemoryStream(idr.GetValue(6) as byte[]));
试试
ericzhangbo1982111 2008-03-07
  • 打赏
  • 举报
回复
(byte[])idr[6];
(byte[])idr["name"];
jinmiwa 2008-03-07
  • 打赏
  • 举报
回复
System.IO.FileStream fs = new System.IO.FileStream(imagePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] b = new byte[fs.Length];
fs.Read(b, 0, b.Length);
fs.Close();

或者


Stream myStream=new MemoryStream();
bitmap.Save(myStream,img.RawFormat);
int imgdatalen =Convert.ToInt32(myStream.Length);
myStream.Position = 0;
BinaryReader br = new BinaryReader(myStream);
byte[] imagebyte=br.ReadBytes((int)myStream.Length);
br.Close();
myStream.Close();



110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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