有数据库中有一个字段为varBinary型,我在保存时使用的SqlDbType.VarBinary类型,参数为byte[]数组。在C#中我该怎样读取它并放到一个byte[]数组中?SqlDataReader dr = cmd.ExecuteReader();
byte[] datas;
while(dr.Read())
{
//datas = dr.GetString(0);
}
显然,GetString是不满足使用的。但我应该使用什么类型。
byte[] datas;
while(dr.Read())
{
//datas = dr.GetString(0);
}
显然,GetString是不满足使用的。但我应该使用什么类型。
datas = (Byte[])dr[0];
写到byte[]中后再从byte[]写到stream