How to Insert Videos in Sql-Server using C#?Storing Images in DB - Yea or Nay?IIS7 - The request filtering module is configured to deny a request that exceeds the request content lengthWhat is the difference between String and string in C#?Cast int to enum in C#Add a column with a default value to an existing table in SQL ServerHow do I enumerate an enum in C#?How to return only the Date from a SQL Server DateTime datatypeHow to check if a column exists in a SQL Server table?How to concatenate text from multiple rows into a single text string in SQL server?What are the correct version numbers for C#?Inserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?

As an employer, can I compel my employees to vote?

Norwegian refuses EU delay (4.7 hours) compensation because it turned out there was nothing wrong with the aircraft

Is this a Sherman, and if so what model?

Circle divided by lines between a blue dots

Manager encourages me to take day of sick leave instead of PTO, what's in it for him?

How do I clean sealant/silicon from a glass mirror?

CDG baggage claim before or after immigration?

Writing a letter of recommendation for a mediocre student

Can one guy with a duplicator initiate a nuclear apocalypse?

How to manage expenditure when billing cycles and paycheck cycles are not aligned?

Do liquid propellant rocket engines experience thrust oscillation?

Where Does VDD+0.3V Input Limit Come From on IC chips?

I reverse the source code, you negate the input!

Pseudo Game of Cups in Python

Leaving a job that I just took based on false promise of a raise. What do I tell future interviewers?

Do the villains know Batman has no superpowers?

As a discovery writer, how do I complete an unfinished novel (which has highly diverged from the original plot ) after a time-gap?

Can planetary bodies have a second axis of rotation?

Is it true that, "just ten trading days represent 63 per cent of the returns of the past 50 years"?

Wired to Wireless Doorbell

How do rulers get rich from war?

Would Taiwan and China's dispute be solved if Taiwan gave up being the Republic of China?

Did Apollo carry and use WD40?

Is Zack Morris's 'time stop' ability in "Saved By the Bell" a supernatural ability?



How to Insert Videos in Sql-Server using C#?


Storing Images in DB - Yea or Nay?IIS7 - The request filtering module is configured to deny a request that exceeds the request content lengthWhat is the difference between String and string in C#?Cast int to enum in C#Add a column with a default value to an existing table in SQL ServerHow do I enumerate an enum in C#?How to return only the Date from a SQL Server DateTime datatypeHow to check if a column exists in a SQL Server table?How to concatenate text from multiple rows into a single text string in SQL server?What are the correct version numbers for C#?Inserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















When I try to save a video in Sql server, i'm facing to this kind of error bellow:
The request filtering module is configured to deny a request that exceeds the request content length.



//Converting a file Uploaded in byte before inserting it in DB.

using (BinaryReader br = new BinaryReader(fs))

byte[] bytes = br.ReadBytes((Int32)fs.Length);
string constr = (@"Data Source=(localdb)MSSQLLocalDB;....");

using (SqlConnection con = new SqlConnection(constr))

string query = "insert into tblFiles values (@Name, @ContentType, @Data)";

using (SqlCommand cmd = new SqlCommand(query))

//// ????





//The Kind of table i'm Using in Sql_Server



CREATE TABLE tblFiles(Id int IDENTITY PRIMARY KEY,Name 
VARCHAR(100) NOT NULL,
ContentType NVARCHAR(4000)NOT NULL, Data VARBINARY(MAX)NOT
NULL);









share|improve this question





















  • 5





    I would urge you not to store videos directly in the database like this. Why not store them on disc and put the path and filename in the database?

    – Sean Lange
    Mar 28 at 14:59












  • Or use BLOB ? (But yeah, I would store the video on disc instead of DB)

    – Cid
    Mar 28 at 15:00







  • 5





    if the problem is "The request filtering module is configured to deny a request that exceeds the request content length.", then ... the problem has nothing to do with the storage location (and in particular: is nothing to do with SQL Server, although I agree with @SeanLange that storing this in a database is a bad choice) - you'll get the same problem where-ever you store it - the problem is that it is too big, meaning: your web-server is configured to treat that as malicious. For good reason. It will be the same size no matter where/how you store it.

    – Marc Gravell
    Mar 28 at 15:01







  • 1





    Possible duplicate of IIS7 - The request filtering module is configured to deny a request that exceeds the request content length

    – NineBerry
    Mar 28 at 15:11

















2















When I try to save a video in Sql server, i'm facing to this kind of error bellow:
The request filtering module is configured to deny a request that exceeds the request content length.



//Converting a file Uploaded in byte before inserting it in DB.

using (BinaryReader br = new BinaryReader(fs))

byte[] bytes = br.ReadBytes((Int32)fs.Length);
string constr = (@"Data Source=(localdb)MSSQLLocalDB;....");

using (SqlConnection con = new SqlConnection(constr))

string query = "insert into tblFiles values (@Name, @ContentType, @Data)";

using (SqlCommand cmd = new SqlCommand(query))

//// ????





//The Kind of table i'm Using in Sql_Server



CREATE TABLE tblFiles(Id int IDENTITY PRIMARY KEY,Name 
VARCHAR(100) NOT NULL,
ContentType NVARCHAR(4000)NOT NULL, Data VARBINARY(MAX)NOT
NULL);









share|improve this question





















  • 5





    I would urge you not to store videos directly in the database like this. Why not store them on disc and put the path and filename in the database?

    – Sean Lange
    Mar 28 at 14:59












  • Or use BLOB ? (But yeah, I would store the video on disc instead of DB)

    – Cid
    Mar 28 at 15:00







  • 5





    if the problem is "The request filtering module is configured to deny a request that exceeds the request content length.", then ... the problem has nothing to do with the storage location (and in particular: is nothing to do with SQL Server, although I agree with @SeanLange that storing this in a database is a bad choice) - you'll get the same problem where-ever you store it - the problem is that it is too big, meaning: your web-server is configured to treat that as malicious. For good reason. It will be the same size no matter where/how you store it.

    – Marc Gravell
    Mar 28 at 15:01







  • 1





    Possible duplicate of IIS7 - The request filtering module is configured to deny a request that exceeds the request content length

    – NineBerry
    Mar 28 at 15:11













2












2








2








When I try to save a video in Sql server, i'm facing to this kind of error bellow:
The request filtering module is configured to deny a request that exceeds the request content length.



//Converting a file Uploaded in byte before inserting it in DB.

using (BinaryReader br = new BinaryReader(fs))

byte[] bytes = br.ReadBytes((Int32)fs.Length);
string constr = (@"Data Source=(localdb)MSSQLLocalDB;....");

using (SqlConnection con = new SqlConnection(constr))

string query = "insert into tblFiles values (@Name, @ContentType, @Data)";

using (SqlCommand cmd = new SqlCommand(query))

//// ????





//The Kind of table i'm Using in Sql_Server



CREATE TABLE tblFiles(Id int IDENTITY PRIMARY KEY,Name 
VARCHAR(100) NOT NULL,
ContentType NVARCHAR(4000)NOT NULL, Data VARBINARY(MAX)NOT
NULL);









share|improve this question
















When I try to save a video in Sql server, i'm facing to this kind of error bellow:
The request filtering module is configured to deny a request that exceeds the request content length.



//Converting a file Uploaded in byte before inserting it in DB.

using (BinaryReader br = new BinaryReader(fs))

byte[] bytes = br.ReadBytes((Int32)fs.Length);
string constr = (@"Data Source=(localdb)MSSQLLocalDB;....");

using (SqlConnection con = new SqlConnection(constr))

string query = "insert into tblFiles values (@Name, @ContentType, @Data)";

using (SqlCommand cmd = new SqlCommand(query))

//// ????





//The Kind of table i'm Using in Sql_Server



CREATE TABLE tblFiles(Id int IDENTITY PRIMARY KEY,Name 
VARCHAR(100) NOT NULL,
ContentType NVARCHAR(4000)NOT NULL, Data VARBINARY(MAX)NOT
NULL);






c# asp.net sql-server






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 15:06









Daniel Shillcock

1,5201 gold badge23 silver badges29 bronze badges




1,5201 gold badge23 silver badges29 bronze badges










asked Mar 28 at 14:57









JosephJoseph

111 bronze badge




111 bronze badge










  • 5





    I would urge you not to store videos directly in the database like this. Why not store them on disc and put the path and filename in the database?

    – Sean Lange
    Mar 28 at 14:59












  • Or use BLOB ? (But yeah, I would store the video on disc instead of DB)

    – Cid
    Mar 28 at 15:00







  • 5





    if the problem is "The request filtering module is configured to deny a request that exceeds the request content length.", then ... the problem has nothing to do with the storage location (and in particular: is nothing to do with SQL Server, although I agree with @SeanLange that storing this in a database is a bad choice) - you'll get the same problem where-ever you store it - the problem is that it is too big, meaning: your web-server is configured to treat that as malicious. For good reason. It will be the same size no matter where/how you store it.

    – Marc Gravell
    Mar 28 at 15:01







  • 1





    Possible duplicate of IIS7 - The request filtering module is configured to deny a request that exceeds the request content length

    – NineBerry
    Mar 28 at 15:11












  • 5





    I would urge you not to store videos directly in the database like this. Why not store them on disc and put the path and filename in the database?

    – Sean Lange
    Mar 28 at 14:59












  • Or use BLOB ? (But yeah, I would store the video on disc instead of DB)

    – Cid
    Mar 28 at 15:00







  • 5





    if the problem is "The request filtering module is configured to deny a request that exceeds the request content length.", then ... the problem has nothing to do with the storage location (and in particular: is nothing to do with SQL Server, although I agree with @SeanLange that storing this in a database is a bad choice) - you'll get the same problem where-ever you store it - the problem is that it is too big, meaning: your web-server is configured to treat that as malicious. For good reason. It will be the same size no matter where/how you store it.

    – Marc Gravell
    Mar 28 at 15:01







  • 1





    Possible duplicate of IIS7 - The request filtering module is configured to deny a request that exceeds the request content length

    – NineBerry
    Mar 28 at 15:11







5




5





I would urge you not to store videos directly in the database like this. Why not store them on disc and put the path and filename in the database?

– Sean Lange
Mar 28 at 14:59






I would urge you not to store videos directly in the database like this. Why not store them on disc and put the path and filename in the database?

– Sean Lange
Mar 28 at 14:59














Or use BLOB ? (But yeah, I would store the video on disc instead of DB)

– Cid
Mar 28 at 15:00






Or use BLOB ? (But yeah, I would store the video on disc instead of DB)

– Cid
Mar 28 at 15:00





5




5





if the problem is "The request filtering module is configured to deny a request that exceeds the request content length.", then ... the problem has nothing to do with the storage location (and in particular: is nothing to do with SQL Server, although I agree with @SeanLange that storing this in a database is a bad choice) - you'll get the same problem where-ever you store it - the problem is that it is too big, meaning: your web-server is configured to treat that as malicious. For good reason. It will be the same size no matter where/how you store it.

– Marc Gravell
Mar 28 at 15:01






if the problem is "The request filtering module is configured to deny a request that exceeds the request content length.", then ... the problem has nothing to do with the storage location (and in particular: is nothing to do with SQL Server, although I agree with @SeanLange that storing this in a database is a bad choice) - you'll get the same problem where-ever you store it - the problem is that it is too big, meaning: your web-server is configured to treat that as malicious. For good reason. It will be the same size no matter where/how you store it.

– Marc Gravell
Mar 28 at 15:01





1




1





Possible duplicate of IIS7 - The request filtering module is configured to deny a request that exceeds the request content length

– NineBerry
Mar 28 at 15:11





Possible duplicate of IIS7 - The request filtering module is configured to deny a request that exceeds the request content length

– NineBerry
Mar 28 at 15:11












2 Answers
2






active

oldest

votes


















1
















just add it with parameters like any other datatypes:



cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = name;
cmd.Parameters.Add("@Data", SqlDbType.VarBinary).Value = bytes;
cmd.Parameters.Add("@ContentType", SqlDbType.NVarChar).Value = contentType;





share|improve this answer
































    1
















    Rather then trying to codify the video data into bytes and store it in the database it would be better practice to store the video on your disk and store the path to the video in your database. Thus rather then bloating your database you have more efficient design.



    Storing Images in DB - Yea or Nay?






    share|improve this answer






















    • 1





      I totally agree.

      – heuristican
      Mar 28 at 15:08













    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400744%2fhow-to-insert-videos-in-sql-server-using-c%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1
















    just add it with parameters like any other datatypes:



    cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = name;
    cmd.Parameters.Add("@Data", SqlDbType.VarBinary).Value = bytes;
    cmd.Parameters.Add("@ContentType", SqlDbType.NVarChar).Value = contentType;





    share|improve this answer





























      1
















      just add it with parameters like any other datatypes:



      cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = name;
      cmd.Parameters.Add("@Data", SqlDbType.VarBinary).Value = bytes;
      cmd.Parameters.Add("@ContentType", SqlDbType.NVarChar).Value = contentType;





      share|improve this answer



























        1














        1










        1









        just add it with parameters like any other datatypes:



        cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = name;
        cmd.Parameters.Add("@Data", SqlDbType.VarBinary).Value = bytes;
        cmd.Parameters.Add("@ContentType", SqlDbType.NVarChar).Value = contentType;





        share|improve this answer













        just add it with parameters like any other datatypes:



        cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = name;
        cmd.Parameters.Add("@Data", SqlDbType.VarBinary).Value = bytes;
        cmd.Parameters.Add("@ContentType", SqlDbType.NVarChar).Value = contentType;






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 15:03









        Ashkan Mobayen KhiabaniAshkan Mobayen Khiabani

        24.2k19 gold badges72 silver badges129 bronze badges




        24.2k19 gold badges72 silver badges129 bronze badges


























            1
















            Rather then trying to codify the video data into bytes and store it in the database it would be better practice to store the video on your disk and store the path to the video in your database. Thus rather then bloating your database you have more efficient design.



            Storing Images in DB - Yea or Nay?






            share|improve this answer






















            • 1





              I totally agree.

              – heuristican
              Mar 28 at 15:08















            1
















            Rather then trying to codify the video data into bytes and store it in the database it would be better practice to store the video on your disk and store the path to the video in your database. Thus rather then bloating your database you have more efficient design.



            Storing Images in DB - Yea or Nay?






            share|improve this answer






















            • 1





              I totally agree.

              – heuristican
              Mar 28 at 15:08













            1














            1










            1









            Rather then trying to codify the video data into bytes and store it in the database it would be better practice to store the video on your disk and store the path to the video in your database. Thus rather then bloating your database you have more efficient design.



            Storing Images in DB - Yea or Nay?






            share|improve this answer















            Rather then trying to codify the video data into bytes and store it in the database it would be better practice to store the video on your disk and store the path to the video in your database. Thus rather then bloating your database you have more efficient design.



            Storing Images in DB - Yea or Nay?







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 28 at 15:10

























            answered Mar 28 at 15:06









            Joey PhillipsJoey Phillips

            9902 gold badges7 silver badges21 bronze badges




            9902 gold badges7 silver badges21 bronze badges










            • 1





              I totally agree.

              – heuristican
              Mar 28 at 15:08












            • 1





              I totally agree.

              – heuristican
              Mar 28 at 15:08







            1




            1





            I totally agree.

            – heuristican
            Mar 28 at 15:08





            I totally agree.

            – heuristican
            Mar 28 at 15:08


















            draft saved

            draft discarded















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400744%2fhow-to-insert-videos-in-sql-server-using-c%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript