Bitmap bitmap = new Bitmap(stream) 无效参数??
代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
MemoryStream stream = new MemoryStream();
SqlConnection connection = new SqlConnection("Data Source=.;Initial Catalog=gdseal;Persist Security Info=True;User ID=sa;Password=rsrj");
try
{
string imageid = TextBox1.Text.Trim();
connection.Open();
SqlCommand command = new SqlCommand("select sdimage from SealData where code='" + imageid+ "'", connection);
byte[] image = (byte[])command.ExecuteScalar();
stream.Write(image, 0, image.Length);
Bitmap bitmap = new Bitmap(stream);
Response.ContentType = "image/gif";
bitmap.Save(Response.OutputStream, ImageFormat.Gif);
}
finally
{
connection.Close();
stream.Close();
}
}
只是显示数据库中的字段,老出现无效参数?
那位大侠给个代码也行。