最近用MYSQL里面的bolo字段存储了byte[],已经存储成功了,但是读取却读取不成功
求大大们指点下!
存储:
读取:
存入是23817 但是读取的时候只有255,要怎么样才能全部读取出来呢?都是23817这样
yte[] bs=(byte[])dr[8];//dr[8]是数据库中第八列的数据image类型
MemoryStream memorystream=new MemoryStream (bs);
memorystream.Write(bs, 0, bs.Length);
Bitmap image=new Bitmap (memorystream);
pictureBox1.Image =image;
memorystream.Close();
byte[] bs=(byte[])thisreader["image"].tostring();
这里不要.tostring
byte[] bs=(byte[])thisreader["image"];
你在数据库中定义的字段大小有多大。
mssql的话用image类型存图片,byte太短,不够用的,会截断。
肯定是被截断了, 字段是nvarchar(max)吗?
byte[] bs=(byte[])dr[8];//dr[8]是数据库中第八列的数据image类型
MemoryStream memorystream=new MemoryStream (bs);
memorystream.Write(bs, 0, bs.Length);
Bitmap image=new Bitmap (memorystream);
pictureBox1.Image =image;
memorystream.Close();
byte[] bs=(byte[])thisreader["image"].tostring();
这里不要.tostring
byte[] bs=(byte[])thisreader["image"];