Click here to Skip to main content
15,915,702 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am working on my project and trying to upload videos into the data base. but it gives me the error....
C#
protected void Button1_Click(object sender, EventArgs e)
   {
       if (FUVideo.PostedFile != null)
       {
           FileName = Path.GetFileName(FUVideo.PostedFile.FileName);

           //Save files to disk
           FUVideo.SaveAs(Server.MapPath("~/Images/" + FileName));
           videosize = FUVideo.PostedFile.ContentLength;

           // Allow only files less than 2,100,000 bytes (approximately 2 MB) to be uploaded.
           //if (fileSize < 2100000)
           //"Your file was not uploaded because " +
           //                             "it exceeds the 2 MB size limit.";
           videotype = FUVideo.PostedFile.ContentType;
       }
       try
       {
           db1.sqlcmd = new SqlCommand("uspAddVideos");
           using (SqlDataAdapter sda = new SqlDataAdapter())
           {
               db1.sqlcmd.CommandType = CommandType.StoredProcedure;
               db1.sqlcmd.Parameters.AddWithValue("@UserID", UserID);
               db1.sqlcmd.Parameters.AddWithValue("@SubscripID", SubscripID);
               db1.sqlcmd.Parameters.AddWithValue("@Title", Convert.ToString(TBVname.Text.Trim()));
               db1.sqlcmd.Parameters.AddWithValue("@Details", Convert.ToString(TBVDesc.Text.Trim()));
               db1.sqlcmd.Parameters.AddWithValue("@Category", Convert.ToString(TBCategory.Text.Trim()));
               db1.sqlcmd.Parameters.AddWithValue("@Name", FileName);
               db1.sqlcmd.Parameters.AddWithValue("@Url", "~/Images/" + FileName);
               //db1.sqlcmd.Parameters.AddWithValue("@VideoSize", videosize);
               //db1.sqlcmd.Parameters.AddWithValue("@VideoType", videotype);
               db1.sqlcmd.Parameters.Add("@success", SqlDbType.Bit);
               db1.sqlcmd.Parameters["@success"].Direction = ParameterDirection.Output;
               db1.sqlcmd.Connection = db1.sqlcon;
               db1.sqlcon.Open();
               db1.sqlcmd.ExecuteScalar();
               success = (bool)db1.sqlcmd.Parameters["@success"].Value;
           }

       }
       catch (Exception ex)
       {
           Response.Write(ex.Message);
       }
       finally
       {
           if (success == true)
           {
               db1.sqlcon.Close();
           }
           else
           {
           }

           db1.sqlcon.Close();


       }
   }



SQL
Create Proc uspAddVideos
--@VideoSize bigint,@VideoType varchar(100),
@success bit out,
@Name nvarchar(max),@Title nvarchar(100), @Details varchar(250),
@Url varchar(max),@Category varchar(50), @SubscripID int,@UserID int
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRY
INSERT INTO TblVideos (Title,Name, Url, Details, Category, PublishedOn, PublishedBy,SubcriptionId) 
VALUES (@Title,@Name,@Url, @Details,@Category,GETDATE(),@UserID,@SubscripID)
UPDATE TblSubscription SET MaxVideos = MaxVideos -1 WHERE SubscriptionId = @SubscripID
SET @success = 1
END TRY
BEGIN CATCH
SET @success = 0
END CATCH
END



and the error is.....

 Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length exceeded.
Posted

1 solution

 
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