Thursday, February 5, 2009

SQL CE - NText, doesn't support more than 4000 characters

When using SQL CE and trying to insert data with NText type column that has more than 4000 characters I got this error
Type : System.InvalidOperationException, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : @TextContent : String truncation: max=4000, len=27811, value='In the email Content provide the following value,.
When i am looking into this issue, i came to know, that while dealing with NText, we need to add SQLCEParameter like this, to avoid the exception, Changing the command parameters as follows, resolve the issue.
SqlCeParameter textContent;
cmdEmail.Parameters.Add("@ID", ActivityDetails.Email.ID);


textContent = cmdEmail.Parameters.Add("@TextContent", SqlDbType.NText);

textContent.Value = ActivityDetails.Email.TextContent;


Happy Programming

No comments:

Post a Comment