且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从asp.net中的sql表中检索图像

更新时间:2023-02-14 10:25:49

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.