-2
id (int)
name (varchar)
picture (image)
二
id (int)
post (varchar)
age (int)
- 我想先在表中添加一條記錄。
- 然後,我想結合這兩個表使用ID。
- 然後,我想填充一個gridview的帖子是「經理」。
(特別是我想知道如何插入圖像數據庫,以及如何使用網格視圖來顯示它們。)
id (int)
name (varchar)
picture (image)
二
id (int)
post (varchar)
age (int)
(特別是我想知道如何插入圖像數據庫,以及如何使用網格視圖來顯示它們。)
要插入一個圖片到你的表,你可以嘗試的點擊這樣的事情你保存按鈕
3210要從你需要使用一個通用處理器(ashx的)文件,右擊你的項目,然後去添加,然後新的項目,最後一般處理程序的數據庫表中獲取圖像。這裏是你的.ashx文件的代碼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
namespace CwizBankApp
{
/// <summary>
/// Summary description for $codebehindclassname$
/// </summary>
public class ShowImage : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//context.Response.ContentType = "text/plain";
// context.Response.Write("Hello World");
string id =context.Request.QueryString["Id"];
context.Response.ContentType = "image/jpeg";
Stream strm = ShowEmpImg(id);
byte[] buffer = new byte[4096];
int byteSeq = strm.Read(buffer, 0, 4096);
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 4096);
}
}
public Stream ShowEmpImg(string id)
{
DataClasses1DataContext context1 = new DataClasses1DataContext();
var r = (from a in context1.mem_images where a.image_id==id select a).First() ;
return new MemoryStream(r.mem_img.ToArray());
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
然後在你的節目圖像的單擊事件最終或任何這樣做
custImage1.ImageUrl = "~/ShowImage.ashx?Id="+textbox.text
希望這可以幫助你,如果你有進一步的問題,請回覆
是否使用'LINQ-TO-實體?你有什麼嘗試? – gideon 2012-03-14 07:34:20
只是我想要在sql數據庫中存儲圖像,並讓他們回到網格視圖。 – user1191013 2012-03-14 11:49:15
這是gideon的答案嗎?互聯網上有很多關於在數據庫中存儲圖像的信息。回答你的問題需要編寫一個幾乎成熟的應用程序。 – 2012-03-14 13:18:35