如何从sql检索图像到asp页面? [英] how to retrieve images from sql to asp page?

查看:73
本文介绍了如何从sql检索图像到asp页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生;



i从sql检索图像时出现问题。当我点击搜索按钮时,文本将显示在文本字段中但图像崩溃(我想在图像框中显示图像但不显示)。请尽快帮助我。

提前感谢

了解详情请见我的代码。

Dear sir;

i have problem to retrieving image from sql.when i click on the search button the text will be displayed in the text field but image is crashed (i want to show image in image box but does not display). please help me as soon as possible.
thanks in advance
for further detail please see my code.

protected void btnselect_Click(object sender, EventArgs e)
        {
            string table_naame = drp_table.SelectedItem.Text.ToString();
            string number = txtno.Text;
            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                string query = "Select headlines,detail,ImagePath From " + @table_naame + " Where ID=" + @number + "";
                com = new SqlCommand(query, con);
                SqlDataAdapter da = new SqlDataAdapter(com);
                DataTable dt = new DataTable();
                da.Fill(dt);
                txtheaadline.Text = dt.Rows[0]["headlines"].ToString();
                txtdetail.Text = dt.Rows[0]["Detail"].ToString();
                ImageDisplay.ImageUrl = dt.Rows[0]["ImagePath"].ToString();
 }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }

推荐答案

在我看来是图片网址问题。通常,图像URL将是Web应用程序的相对路径。请看下面的帖子



http://stackoverflow.com/questions/4665160/image-url-is-correct-but-image-not-showing [ ^ ]



http://stackoverflow.com / questions / 23693363 / how-to-display-image-using-imageurl-in-c-sharp [ ^ ]
It appears to me as Image URL issue. Usually the Image URL will be a relative path to the web application. Please take a look at the following posts

http://stackoverflow.com/questions/4665160/image-url-is-correct-but-image-not-showing[^]

http://stackoverflow.com/questions/23693363/how-to-display-image-using-imageurl-in-c-sharp[^]


这篇关于如何从sql检索图像到asp页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆