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=2.0.0.0, 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);
cmdEmail.Parameters.Add("@CCRecipients",ActivityDetails.Email.CCRecipients);
textContent = cmdEmail.Parameters.Add("@TextContent", SqlDbType.NText);
textContent.Value = ActivityDetails.Email.TextContent;
cmdEmail.ExecuteNonQuery();
Happy Programming
Thursday, February 5, 2009
Subscribe to:
Posts (Atom)