VS2005中关于在FormView中显示用户的照片的问题, 试了Response.Type="image/jpg";还是不显示照片郁闷..................... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你个完整的数据库中二进制图片读取 protected void Page_Load(object sender, EventArgs e) { if (Request["Pic_ID"] == null) { Response.Redirect(@"~\display\display.aspx"); } else { OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Server.MapPath(@"~\App_Data\DataBase.aspx")); try { con.Open(); OleDbCommand com = new OleDbCommand("select * from Picture where Pic_ID=" + Request["Pic_ID"] + "", con); OleDbDataReader dr = com.ExecuteReader(); dr.Read(); MemoryStream ms = new MemoryStream((Byte[])dr["Pic"]); Bitmap image = new Bitmap(ms); dr.Close(); //Response.ContentType = "image/Gif"; Response.BinaryWrite(ms.ToArray()); // Image1.ImageUrl = "~/display9.jpg"; } catch (Exception error) { //Label1.Text = "处理失败!原因为:" + error.ToString(); } finally { con.Close(); } } } C#中,上传照片 OpenFileDialog ofdg=new OpenFileDialog(); ofdg.Filter = "图片文件(*.jpg;*.gif;*.bmp)|*.jpg;*.gif;*.bmp"; if(ofdg.ShowDialog() == DialogResult.OK) { this.fullname=ofdg.FileName; this.pbphoto.Image = Image.FromFile(this.fullname,true); }读取照片//读取图片流 FileStream fs=File.OpenRead(this.fullname); content=new byte[fs.Length]; fs.Read(content,0,content.Length); fs.Close(); 发布到虚拟空间里, 页面验证控件失效,提交按钮无反应 服务端验证和客户端验证有什么区别 高分求助压力测试工具webload6.0报表的问题 关于ascx调用aspx程序代码的问题 Excel释放进程问题! 使用HttpWebRequest与HttpWebResponse在客户端与服务器互相发送与接收数据的问题. 求助:对于数据库用户名和地址不同的机器如何发布.net程序啊? 高分求救,用vs2005发布网站后,脚本错误 怎样创建二维数组? 能否在关闭浏览器是向数据库写入一条记录!! 时区转换问题!大散分 gridview里使用if判断<%#%>
protected void Page_Load(object sender, EventArgs e)
{
if (Request["Pic_ID"] == null)
{
Response.Redirect(@"~\display\display.aspx");
}
else
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Server.MapPath(@"~\App_Data\DataBase.aspx"));
try
{
con.Open();
OleDbCommand com = new OleDbCommand("select * from Picture where Pic_ID=" + Request["Pic_ID"] + "", con);
OleDbDataReader dr = com.ExecuteReader();
dr.Read();
MemoryStream ms = new MemoryStream((Byte[])dr["Pic"]);
Bitmap image = new Bitmap(ms);
dr.Close();
//Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
// Image1.ImageUrl = "~/display9.jpg";
}
catch (Exception error)
{
//Label1.Text = "处理失败!原因为:" + error.ToString();
}
finally
{
con.Close();
}
}
}
OpenFileDialog ofdg=new OpenFileDialog();
ofdg.Filter = "图片文件(*.jpg;*.gif;*.bmp)|*.jpg;*.gif;*.bmp";
if(ofdg.ShowDialog() == DialogResult.OK)
{
this.fullname=ofdg.FileName;
this.pbphoto.Image = Image.FromFile(this.fullname,true);
}读取照片
//读取图片流
FileStream fs=File.OpenRead(this.fullname);
content=new byte[fs.Length];
fs.Read(content,0,content.Length);
fs.Close();