Answered by:
why can not update string type with length 256?

Question
-
User1215150307 posted
Error is String or binary data would be truncated.
The statement has been terminated.Why can not update string type with length 256?
CryptographyManager defaultCrypto = EnterpriseLibraryContainer.Current.GetInstance<CryptographyManager>(); PasswordObject pwd = new PasswordObject(New_Password.Text.Trim().ToUpper()); byte[] serializedObject = SerializationUtility.ToBytes(pwd); byte[] encrypted = defaultCrypto.EncryptSymmetric("RijndaelManaged", serializedObject); string updateString = "Update UserProfile set Password = '" + Convert.ToBase64String(encrypted) + "', Last_PasswordChange_Date = '" + DateTime.Now.ToString("yyyy-MM-dd 00:00:00") + "' where upper(rtrim(UserID)) = upper(rtrim('" + UserID + "'))";
string error_test = Util.ExecuteDatabase(updateString);
Thursday, June 23, 2011 1:49 AM
Answers
-
User1215150307 posted
discover a trigger write to log which has not 256 length, solved
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, June 26, 2011 10:20 PM
All replies
-
User-336511135 posted
Hi,
Modify the length of Password in UserProfile Table in your database.
This exception occurs when the lenght of the string is greater then the Table column size. replace it to nvarchar(500)
Thursday, June 23, 2011 1:58 AM -
User1215150307 posted
the field modified nvarchar(257) but still get the same error
Thursday, June 23, 2011 2:27 AM -
User-1011137159 posted
Set fields lenth to 100 because that required to more that your insrted text, that might be more than 256 because you are getting this error because your inserted text is more than 256 hence that might be any number which is greater then 256.
Thursday, June 23, 2011 2:45 AM -
User1215150307 posted
i set to 1000 but still get the same error, i have debugged to see the length is exactly 256, why error?
Thursday, June 23, 2011 2:52 AM -
User-336511135 posted
Try to modify this field to nvarchar(MAX).
Thursday, June 23, 2011 3:19 AM -
User1215150307 posted
max also get the same error
Thursday, June 23, 2011 3:48 AM -
User1215150307 posted
discover a trigger write to log which has not 256 length, solved
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, June 26, 2011 10:20 PM