查看: 854|回复: 3
|
救命啊!!怎么insert照片进database啊!!
[复制链接]
|
|
我的database是 sql server 2000,language是 C#
除了insert 照片 as binary,还有别的方法吗?
因为binary 的话,retrieve出来的时候只能一次display一张而已.
有什么办法可以一次display全部照片的(from database)?
[ 本帖最后由 喵喵大战 于 20-12-2006 05:54 PM 编辑 ] |
|
|
|
|
|
|
|
楼主 |
发表于 20-12-2006 05:40 PM
|
显示全部楼层
我的coding,从网站学来的。
一次只能display一张照片
System.Int32 _height = 110;
System.Int32 _width = 200;
string sqlComm ="SELECT UploadID,UploadImage FROM images_upload";
sqlConnection1.Open();
SqlCommand command = new SqlCommand(sqlComm,sqlConnection1);
SqlDataReader dr;
dr = command.ExecuteReader();
Response.ContentType = "image/jpeg";
while (dr.Read())
{
System.Drawing.Image _image= System.Drawing.Image.FromStream( new System.IO.MemoryStream( (byte[])dr["UploadImage"] ) );
System.Drawing.Image _newimage = _image.GetThumbnailImage( _width, _height, null, new System.IntPtr() );
_newimage.Save( System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg );
}
dr.Close();
sqlConnection1.Close(); |
|
|
|
|
|
|
|
发表于 23-12-2006 05:31 PM
|
显示全部楼层
hello dude, try storing the photo to a path, and copy & paste the photo to the specified path mentioned, then when you retreat, call the path then the photo will be display; of course 1 path 1 photo; pm me if you have more difficulties. |
|
|
|
|
|
|
|
发表于 24-12-2006 01:26 AM
|
显示全部楼层
原帖由 喵喵大战 于 20-12-2006 05:40 PM 发表
我的coding,从网站学来的。
一次只能display一张照片
System.Int32 _height = 110;
System.Int32 _width = 200;
string sqlComm ="SELECT UploadID,UploadImage FROM images_upload";
...
如果我没猜错的话, 这应该是你的 record 问题... 你的 record 有几个呀? |
|
|
|
|
|
|
| |
本周最热论坛帖子
|