/// <summary> /// 根据产品Id获得图片 /// </summary> /// <param name="pId"></param> /// <returns></returns> public Image GetImage(string pId) { DBManager vDBManager = new DBManager(); vDBManager.ConnectionOpen(); string sql = "select Img from ProductInfo where ProductId = @pId"; vDBManager.AddParameter("@pId", pId); DataTable dt = vDBManager.Query(sql).Tables[0]; vDBManager.ConnectionClose(); Image img = null; if (dt != null && dt.Rows.Count > 0 &&dt.Rows[0][0] != null && !dt.Rows[0][0].ToString().Equals("")) { MemoryStream stream = new MemoryStream((byte[])dt.Rows[0]["Img"], false); img = Image.FromStream(stream); stream.Close(); stream.Dispose(); } return img; }