Добрый день! По книге этот код должен выводить логотип, а выводит кучку краказяблов типа "GIF89a����..."
| Код | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Web.Configuration;
public partial class Foto : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string strcon = WebConfigurationManager.ConnectionStrings["Pubs"].ConnectionString; SqlConnection con = new SqlConnection(strcon); string sql = "SELECT logo FROM pub_info WHERE pub_id = '1389'"; SqlCommand cmd = new SqlCommand(sql, con);
try { con.Open(); SqlDataReader r = cmd.ExecuteReader(); if (r.Read()) { byte[] bytes = (byte[])r["logo"]; Response.BinaryWrite(bytes); } con.Close(); } finally { con.Close(); } } }
|
|