Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I am able to save the video and the images in the sql database, also I can successfully display the images on browser once stored in the database. The only problem is with the video files. I am unable to retrieve them and display on the aspx page(browser).
Below is the sample code used by me to save the video files in database. Could any one suggest me any options to retrieve and play them.
C#
private DataTable GetVideoInfo()
{
    string connectionString = @"MyDatabase";
    SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM VTable", connectionString);
    DataTable table = new DataTable();
    adapter.Fill(table);
    return table;
}

private DataTable GetSpecificVideo()
{
    string connectionString = @"MyDatabase";
    SqlDataAdapter adapter = new SqlDataAdapter("SELECT ID FROM VTable", connectionString);
    //adapter.SelectCommand.Parameters.Add("@ID", SqlDbType.Int).Value = (int)i;
    DataTable table = new DataTable();
    adapter.Fill(table);
    return table;
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{

}

private DataTable GetSpecificVideo(object i)

//pass the id of the video
{

    connection = new SqlConnection("MyDatabase");

    SqlDataAdapter adapter = new SqlDataAdapter("SELECT Video, ID " + "FROM Vtable WHERE ID = @id", connection);

    adapter.SelectCommand.Parameters.Add("@id", SqlDbType.Int).Value = (int)i;

    DataTable table = new DataTable();

    adapter.Fill(table);

    return table;

}

public SqlConnection connection { get; set; }
protected void Button1_Click(object sender, EventArgs e)
{
    
    int id = Convert.ToInt32(TextBox2.Text);
    Repeater1.DataSource = GetSpecificVideo(id);
    Repeater1.DataBind();
}
}
Posted
v2

1 solution

I have no idea why you can store and retrieve images but not video files; there is no difference. However, for ASP.NET applications, I would recommend to keep both images and video files as file in the server-side file system, under some set of unique names, and store just those names in your database.

For playing you can use, first of all, HTML5 <video> element: https://en.wikipedia.org/wiki/HTML5_video[^].

—SA
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900