Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i upload a video to my database the following massege appear

This webpage is not available

here is my upload code

C#
byte[] buffer;//this is the array of bytes which will hold the data (file)
   SqlConnection connection;
   protected void ButtonUpload_Click(object sender, EventArgs e)
   {
       //check the file
       if (FileUpload1.HasFile && FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
       {
           HttpPostedFile file = FileUpload1.PostedFile;//retrieve the HttpPostedFile object
           buffer = new byte[file.ContentLength];
           int bytesReaded = file.InputStream.Read(buffer, 0, FileUpload1.PostedFile.ContentLength);

           if (bytesReaded > 0)
           {
               try
               {
                   string connectionString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
                   connection = new SqlConnection(connectionString);
                   SqlCommand cmd = new SqlCommand
                       ("INSERT INTO VIDEO (Video, Video_Name, Video_Size) VALUES (@video, @videoName, @videoSize)", connection);
                   cmd.Parameters.Add("@video", SqlDbType.VarBinary, buffer.Length).Value = buffer;
                   cmd.Parameters.Add("@videoName", SqlDbType.NVarChar).Value = FileUpload1.FileName;
                   cmd.Parameters.Add("@videoSize", SqlDbType.BigInt).Value = file.ContentLength;
                   using (connection)
                   {
                       connection.Open();
                       int i = cmd.ExecuteNonQuery();
                       Label1.Text = "uploaded, " + i.ToString() + " rows affected";
                   }
               }
               catch (Exception ex)
               {
                   Label1.Text = ex.Message.ToString();
               }
           }

       }
       else
       {
           Label1.Text = "Choose a valid video file";
       }
   }
Posted
Comments
vijay__p 11-Jul-13 23:28pm    
What is the size of your file?
Did you set size in maxRequestLength in web.config.
Check below article for more information.
http://www.codeproject.com/Articles/10842/Setting-up-Web-config-to-allow-uploading-of-large

1 solution

try to follow the below article:

http://videoplayer.codeplex.com/[^]
 
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