如何从asp.net中的sql表中检索图像 [英] how to retrieve an image from the sql table in asp.net

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

问题描述


我被设计成一个像userdetails这样的表,其中的字段是userid,userimg,username我如何在gridview中显示所有字段,我无法在gridview中显示图像,
请任何人告诉我解决方案.


谢谢你


i was designed a table like userdetails in this the fields are userid,userimg,username how can i display all the fields in a gridview ,i can''t display the image in a gridview,
pls any one can tell me the solution.


Thank u

推荐答案

MSDN [ ^ ]这应该可以帮助...

下次尝试使用Google:我发现它是简单搜索中的第一个链接:从您的问题中粘贴的在gridview中显示图像" ...

Google可以为您节省很多时间,而不是问一个问题!
There is a good tutorial on MSDN[^] which should help...

Try Google next time: I found this as the first link in a simple search: "display the image in a gridview" pasted from your question...

Google can save you a lot of time, as opposed to asking a question!


con1 = new SqlConnection();
                con1.ConnectionString = @"Data Source=KOL-00D55-SRVMR\SRVMRSQL2005;Initial Catalog=AdventureWorks;User ID=student";
                con1.Open();
                SqlCommand sqlquery = new SqlCommand("SELECT pic FROM imagetable WHERE id =1", con1);
                SqlDataAdapter da = new SqlDataAdapter(sqlquery);
                DataSet ds = new DataSet();
                da.Fill(ds);
                //if (dr.Read())
                //{
              
                //ms.re
                    byte[] arr=new byte[0];
                arr=(byte[])ds.Tables[0].Rows[0][0];
                MemoryStream ms = new MemoryStream(arr);
                pictureBox1.Image = Image.FromStream(ms);
                //Image str;



http://support.microsoft.com/kb/317701 [



http://support.microsoft.com/kb/317701[^]


希望
Hope this[^] might help you.


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

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