【发布时间】:2013-06-19 03:41:09
【问题描述】:
这是我在数据库中的表:
我像这样读取数据库:
DataClassesDataContext db = new DataClassesDataContext();
usertable thisuser = db.usertables.First(p => p.username == User.Identity.Name);
所以,thisuser.picture 是图像的句柄。但是如何在我的页面上的 asp:image 控件中显示它?
编辑 我用这段代码保存图片:
DataClassesDataContext db = new DataClassesDataContext();
usertable thisuser = db.usertables.First(p => p.username == User.Identity.Name);
byte[] filebyte = FileUpload1.FileBytes;
System.Data.Linq.Binary fileBinary = new System.Data.Linq.Binary(filebyte);
thisuser.picture = fileBinary;
db.SubmitChanges();
有什么问题吗?
【问题讨论】:
-
你使用什么格式的图片?此外,
image是 SQL Server 中已弃用的类型 - 您可能希望改用varbinary。 -
通常图片格式为
jpg -
我不得不说这是一个完美的:你试过什么?。说真的,如果你给我们看,这篇文章会受益匪浅。