无法从数据库中检索图像。运行时没有错误〜但根本没有img显示

时间:2016-12-20 13:19:04

标签: c# asp.net sql-server

C#代码

public partial class photorecognize : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\registerdatabase.mdf;Integrated Security=True");

    protected void Page_Load(object sender, EventArgs e)
    {
        con.Open();

        SqlCommand cmd = con.CreateCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "select image from [picture] where username = 'wenhao123'";

        cmd.ExecuteNonQuery();

        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);

        DataListABC.DataSource = dt;
        DataListABC.DataBind();

        con.Close();
    }
}

asp.net

<asp:DataList ID="DataListABC" runat="server" Height="208px" Width="226px">          
    <ItemTemplate>
        <asp:Image ID="Image1" runat="server" />
    </ItemTemplate>
</asp:DataList>

数据库:

enter image description here

0 个答案:

没有答案