我们如何在asp.net C#中使用数据库在网格视图中播放视频? [英] How can we play video in grid view using database in asp.net C# ?

查看:139
本文介绍了我们如何在asp.net C#中使用数据库在网格视图中播放视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何使用asp.net C#中的数据库在网格视图中播放视频?

为此,我们可以使用ID从数据库中获取视频名称.
然后播放Folder中的视频.

How can we play video in grid view using database in asp.net C# ?

For this, we can fetch video name from database using ID.
Then play Video from Folder.

推荐答案

将此内容写在CS文件上,并修改视频位置之类的内容
符合您的位置
Write this on CS file and modify the things like video location
accroding to your location
string strSQL = "select * from videos where videosong_loc='" + play + "'";
            SqlConnection sconn = new SqlConnection(@"Data Source=.\sqlexpress;Initial Catalog=db;Integrated Security=True");

            SqlCommand scomm = new SqlCommand(strSQL, sconn);
            sconn.Open();
            SqlDataReader sreader = scomm.ExecuteReader();
            if (sreader.Read())
            {
                string Str = "videos\\" + sreader[1].ToString();
                string text = "<embed src='" + Str + "' height='300' width='500'><noembed>Sorry, your browser doesn't support the embedding of multimedia.</noembed></embed>";
                //Response.Write(text);
                Literal1.Text = text;
                sreader.Close();
                sconn.Close();
            }


写在源代码上


Write This On Source Code

<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
   <columns>
      <asp:templatefield>      
          <itemtemplate>
              <asp:literal id="Literal1" runat="server"></asp:literal>
          </itemtemplate>
      </asp:templatefield>
   </columns>
</asp:gridview>


这篇关于我们如何在asp.net C#中使用数据库在网格视图中播放视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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