Image.aspx 頁面protected void Page_Load(object sender,EventArgs e){ if(!IsPostBack) { string id=Request.QueryString["Id"].ToString(); SqlConnection con=new SqlConnection("server=PC-PC\\SQL2005;database=UUU1;User Id=sa;Password=sasa"); con.Open(); string strSql="select * from Customer where Id"+id; SqlCommand com=new SqlCommand(strSql,con); SqlDataReader dr=com.ExecuteReader(); if(dr.Read()) { Response.BinaryWrite((byte[])dr["Image"]); } con.Close(); }}this.Image1.ImageUrl="Image.aspx?Id"+id其中數(shù)據(jù)庫中Image字段類型為Image,請問高手上邊代碼有什么問題?
2 回答

皈依舞
TA貢獻1851條經(jīng)驗 獲得超3個贊
SqlDataReader dr=com.ExecuteReader(); 使用的時候建議用
using(SqlDataReader dr=com.ExecuteReader();){
}
因為這個東西要手動關(guān)閉。用using會自動釋放的。
還有就是樓上說過的string類型和int類型相加的問題

ABOUTYOU
TA貢獻1812條經(jīng)驗 獲得超5個贊
少了一個 = 等號
string strSql="select * from Customer where Id="+id;
string strSql="select * from Customer where Id"+id;
- 2 回答
- 0 關(guān)注
- 371 瀏覽
添加回答
舉報
0/150
提交
取消