代码是:
this.sqlCommand1.CommandText = "Select * from tbl_imagestore where id = @id";
System.Data.SqlClient.SqlParameter idPara = new System.Data.SqlClient.SqlParameter("@id",SqlDbType.Int,0);
idPara.Value = imgid;
this.sqlCommand1.Parameters.Add(idPara); System.Data.SqlClient.SqlDataReader dr; this.sqlConnection1.Open();
dr = this.sqlCommand1.ExecuteReader();
while (dr.Read())
{
this.Response.Clear();
this.Response.Write("标题:"+dr["imgtitle"].ToString());
this.Response.Write("<br>"); this.Response.Write("文件类型::"+dr["imgtype"].ToString());
this.Response.Write("<br>"); this.Response.BinaryWrite((byte[])dr["imgdata"]); } dr.Close();
this.sqlConnection1.Close();
执行后的效果是:标题:me1
文件类型::image/pjpeg
?1ifII* ????(1?2?i???ćЀЀ"PanasonicDMC-FX1HHVer1.042004图片时乱码,是什么原因呢?
this.sqlCommand1.CommandText = "Select * from tbl_imagestore where id = @id";
System.Data.SqlClient.SqlParameter idPara = new System.Data.SqlClient.SqlParameter("@id",SqlDbType.Int,0);
idPara.Value = imgid;
this.sqlCommand1.Parameters.Add(idPara); System.Data.SqlClient.SqlDataReader dr; this.sqlConnection1.Open();
dr = this.sqlCommand1.ExecuteReader();
while (dr.Read())
{
this.Response.Clear();
this.Response.Write("标题:"+dr["imgtitle"].ToString());
this.Response.Write("<br>"); this.Response.Write("文件类型::"+dr["imgtype"].ToString());
this.Response.Write("<br>"); this.Response.BinaryWrite((byte[])dr["imgdata"]); } dr.Close();
this.sqlConnection1.Close();
执行后的效果是:标题:me1
文件类型::image/pjpeg
?1ifII* ????(1?2?i???ćЀЀ"PanasonicDMC-FX1HHVer1.042004图片时乱码,是什么原因呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货