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>
数据库: