I have a nvarchar(50) field in my table. When I save a string with 12 character Length for example, it saves the string with 50 character length. Actually it adds a space character at the end of the string. Should I select another data type?
tmp_Person.NameFamily = txt_NameFamily.Text.Trim();
PersonKBBSHDataContext.PersonInfos.InsertOnSubmit(tmp_Person);
PersonKBBSHDataContext.SubmitChanges();
When I save a string directly (in SQL Server) in the NameFamily field of the table, everything is fine.
I had same problem. Remove .IsFixedLength() from Nvarchar properties in Mapping class and my problem solved.
Me.Property(Function(t) t.Description).IsFixedLength().HasMaxLength(500)
Replaced with
Me.Property(Function(t) t.Description).HasMaxLength(500)
If using the Entity Framework, set the Fixed Length property to true on your NVarchar fields.
You can still use the Trim however that is just to 'fix' the textBox.Text value and has nothing to do with the database.
I found the problem. I just added my table again in the .dbml file and everything went fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With