0

我无法显示用户在注册时上传的个人资料图片。图像的路径存储在数据库中,图像存储在目录 /data/ 中。imageURL 对我不起作用。代码是:(.cs)

protected void Page_Load(object sender, EventArgs e)
{
    string us = (string)Session["userid"];
    if (!Page.IsPostBack)
    {     
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cc"].ConnectionString);
        SqlCommand cmd = new SqlCommand("select imgpath from reg where userid='" + us + "'", con);
        con.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            Image1.ImageUrl = dr[0].ToString();
        }
        con.Close();
    }
} 
4

0 回答 0