Click here to Skip to main content
15,112,662 members
Please Sign up or sign in to vote.
1.57/5 (3 votes)
See more:
VB
Hi sir,
     Tell me the steps to  compress the video file and stored in db using asp.net c#. Kindly give me the solution for this problem.
Posted
Comments
Sibasisjena 8-Jan-14 3:30am
   
If you want to store the video file in your application then check my solution.

If you want to store the video file in your application then go through the bellow link:

Video Uploader Control for SQL Server[^]
   
Below is the code snippet ....
It will work...

C#
using (BinaryReader br = new BinaryReader(FileUpload1.PostedFile.InputStream))
        {
            byte[] bytes = br.ReadBytes((int)FileUpload1.PostedFile.InputStream.Length);
            string strConnString = 'give the connection string';
            using (SqlConnection con = new SqlConnection(strConnString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "insert into tblFiles(Name, ContentType, Data) values (@Name, @ContentType, @Data)";
                    cmd.Parameters.AddWithValue("@Name", Path.GetFileName(FileUpload1.PostedFile.FileName));
                    cmd.Parameters.AddWithValue("@ContentType", "video/mp4");
                    cmd.Parameters.AddWithValue("@Data", bytes);
                    cmd.Connection = con;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
        }


Let me know if it helps or not..
   

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