这是以前写的一段读取image的代码
<script runat=server>
private void Page_Load(Object sender, System.EventArgs e)
{
string imgid =Request.QueryString["imgid"];
string connstr="server=(local);database=ImageStore;Trusted_Connection=yes";
string sql="SELECT imgdata, imgtype FROM ImageStore WHERE id = '"+ imgid + "'";
SqlConnection connection = new SqlConnection(connstr);
SqlCommand command = new SqlCommand(sql, connection);
connection.Open();
SqlDataReader dr = command.ExecuteReader();if(dr.Read())
{
Response.ContentType = dr["imgtype"].ToString();
Response.BinaryWrite( (byte[]) dr["imgdata"] );
}
connection.Close();
}
</script>
<script runat=server>
private void Page_Load(Object sender, System.EventArgs e)
{
string imgid =Request.QueryString["imgid"];
string connstr="server=(local);database=ImageStore;Trusted_Connection=yes";
string sql="SELECT imgdata, imgtype FROM ImageStore WHERE id = '"+ imgid + "'";
SqlConnection connection = new SqlConnection(connstr);
SqlCommand command = new SqlCommand(sql, connection);
connection.Open();
SqlDataReader dr = command.ExecuteReader();if(dr.Read())
{
Response.ContentType = dr["imgtype"].ToString();
Response.BinaryWrite( (byte[]) dr["imgdata"] );
}
connection.Close();
}
</script>
數據庫中的每個記錄都有其相互對應的Image值的字段先從數據庫中提取相應記錄的圖片,把其幫定到一列上.
然後,這張圖片是有Link的,Link到下個畫面,顯示該記錄的詳細信息.請教如何實現?ps:縮略圖怎樣建立?