c# - SQL Server: String or Binary Would be Truncated ASP.NET -


so i've been working on page allow users submit content, , on page seems work when comes communicating sql server error keeps getting thrown.
error says process has been terminated since string or binary truncated.

the error receiving.


here code using handle communications server.

using (sqlconnection connection = new sqlconnection(@"data source=(localdb)\mssqllocaldb;attachdbfilename=""c:\users\will\documents\visual studio 2015\websites\inshort\app_data\aspnetdb.mdf"";integrated security=true"))             {                 sqlcommand cmd = new sqlcommand("insert aspnet_newscontent (author, username, date, category, content, description) values (@author, @username, @date, @category, @content, @description)");                 cmd.commandtype = system.data.commandtype.text;                 cmd.connection = connection;                 if (nameinput.text != "")                 {                     cmd.parameters.addwithvalue("@author", nameinput.text);                 }                 else if (nameinput.text == "")                 {                     cmd.parameters.addwithvalue("@author", "anonymous");                 }                 cmd.parameters.addwithvalue("@username", userid);                 cmd.parameters.addwithvalue("@date", datetime.today);                 cmd.parameters.addwithvalue("@category", categoryid);                 cmd.parameters.addwithvalue("@content", content.text);                 cmd.parameters.addwithvalue("@description", description.text);                 connection.open();                 cmd.executenonquery();             } 

this issue caused when trying insert values in column greater max size of column specified.

see this


Comments