您的当前位置:首页正文

C#存取SqlServer中的Image类型

2020-11-09 来源:欧得旅游网

}

取:

public void GetImage()

{

SqlCommand cmd = new SqlCommand(@"SELECT name, photo FROM Temp", sqlConn);
sqlConn.Open();
SqlDataReader reader = cmd .ExecuteReader();
if (reader.Read())
{
image_filename= (string) reader.GetValue(0);
byte[] image_bytes = (byte[]) reader.GetValue(1);
MemoryStream ms = new MemoryStream(image_bytes);
Bitmap bmap = new Bitmap(ms);
return bmap;

}

}

显示全文