图像未显示. [英] Image is not displaying.

查看:104
本文介绍了图像未显示.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在从数据库中检索图像名称并分配给图像控件,但是图像未显示........
请检查以下代码..

Hi ,
I am retrieving the image name from the database and assigning to the image control,but image is not displaying........
please go through the below code..

SqlConnection con = new SqlConnection("user id=sa;password=exp2oo8@r2;database=praveen1988");
           SqlCommand cmd = new SqlCommand("select UImage from Information where Username='" + txtusername.Text + "'", con);
           if(con.State == ConnectionState.Closed)
           con.Open();
            s = cmd.ExecuteScalar().ToString();
           if(s==null)
           {
               Response.Write("no image");
           }
           else
           {
               //Image1.Visible = true;
              Image1.ImageUrl = Server.MapPath("~/Images/" + s);
               //Image1.ImageUrl = s;

           }

推荐答案



这不是从数据库显示图像的确切方法.如果要显示数据库中的图像,请使用 Asp.net处理程序 [ C#从数据库保存和加载图像 [ ^ ]

祝一切顺利.
--AK
Hi,

This is not the exact way to display images from database. If you want to display images from database then use Asp.net Handler[^].
Refer this link to have a complete article of displaying and storing images in database.

C# Save and Load Image from Database[^]

All the best.
--AK


这篇关于图像未显示.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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