Hi, all,
I am trying to execute an insert command into the database and one of the columns is of type nvarchar(MAX). Insert command is created by using .NET SqlCommand class and each of the parameters is represented by one SqlParameter object.
My command gets executed always, but when I pass string which length is large (10000+ characters) and which is used as a value for the SqlParameter mapped to the column of type nvarchar(MAX) after the insertion, that particular column is left empty. I repeat, no exception is thrown, INSERT command is executed, but column is empty.
Following examples are how I've tried to create 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 solution gave result. If anyone knows what is the problem please tell me.
I am using MS SQL Server 2008.
Thanks in advance.