The space character at the end of the line when stored in the database

I have a field nvarchar(50)in my table. For example, when I save line c 12 character Length, it saves line c 50 character length. In fact, it adds a space at the end of the line. Should I choose a different data type?

tmp_Person.NameFamily = txt_NameFamily.Text.Trim();
PersonKBBSHDataContext.PersonInfos.InsertOnSubmit(tmp_Person);
PersonKBBSHDataContext.SubmitChanges();

When I save a row directly (in SQL Server ) to a NameFamilytable field , everything is fine.

+5
source share
4 answers

I found a problem. I just added the table again to the file .dbmland everything went fine.

+1
source

If you use a platform Entity Framework, set the property Fixed Lengthvalue truein the field NVarchar.

Trim, "" textBox.Text .

+1

I had the same problem. Remove .IsFixedLength () from the Nvarchar properties in the Mapping class and my problem is resolved.

Me.Property(Function(t) t.Description).IsFixedLength().HasMaxLength(500)

Replaced by

Me.Property(Function(t) t.Description).HasMaxLength(500)
+1
source

Use Trim(txt_NameFamily.Text)

-2
source

All Articles