I am trying to execute the insert command in the database, and one of the columns is of type nvarchar (MAX). The Insert command is created using the .NET SqlCommand class, and each parameter is represented by a single SqlParameter object.
My command is always executed, but when I pass a row that is long (10000+ characters) and which is used as the value for the SqlParameter mapped to a column of type nvarchar (MAX) after insertion, that particular column remains empty. I repeat, the exception is not thrown, the INSERT command is executed, but the column is empty.
The following are examples of how I tried to create the parameter:
// message is the large string variable // first solution insertCommand.Parameters.Add("@message", SqlDbType.NVarChar, -1); // second solution insertCommand.Parameters.Add("@message", SqlDbType.NVarChar, message.Length); // third solution insertCommand.Parameters.Add("@message", SqlDbType.NVarChar, message.Length * 2);
None of these solutions yielded results. If anyone knows what the problem is, tell me.
I am using MS SQL Server 2008.
Thanks in advance.
vukashin
source share