Click here to Skip to main content
15,867,765 members
Articles / Web Development / ASP.NET

Video Uploader Control for SQL Server

Rate me:
Please Sign up or sign in to vote.
4.54/5 (31 votes)
28 Nov 2007CPOL2 min read 287.1K   9.9K   124  
Upload and insert video, audio, or image to SQL Server, and show it in an ASPX page.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ButtonBind_Click(object sender, EventArgs e)
    {
        GridView1.DataSource = GetVideoInfo();
        GridView1.DataBind();
    }

    private DataTable GetVideoInfo()
    {
        string connectionString = ConfigurationManager.ConnectionStrings["uploadConnectionString"].ConnectionString;
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Videos", connectionString);
        DataTable table = new DataTable();
        adapter.Fill(table);
        return table;
    }

    private DataTable GetSpecificVideo(object i)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["uploadConnectionString"].ConnectionString;
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT Video, ID FROM Videos WHERE ID = @id", connectionString);
        adapter.SelectCommand.Parameters.Add("@id", SqlDbType.Int).Value = (int)i;
        DataTable table = new DataTable();
        adapter.Fill(table);
        return table;
    }
    protected void ButtonShowVideo_Click(object sender, EventArgs e)
    {
        Repeater1.DataSource = GetSpecificVideo(2);
        Repeater1.DataBind();
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer Business Development Gate
Egypt Egypt

Comments and Discussions