我正在尝试从数据库中获取图像的图像路径并将其显示在图像控件中,但图像未显示。我试过了:
public void FetchQimage()
{
connection.Open();
SqlCommand cmd = new SqlCommand("select image_path from Questionimage where sub_code = '" + Session["subject"] + "' ", connection);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
// for (int i = 0; i <= dt.Rows.Count - 1; i++)
// {
Image3.ImageUrl = dt.Rows[0]["image_path"].ToString();
}
}
图像路径的格式为:D:\ Project \ projectxyz \ image