Primary Key of string values (trims spaces from the end of strings) causes unique violation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm loading a key values into a database and two may be identical except for maybe 1 or 2 trailing spaces. This causes a unique constraint error because for some reason it's trimming the string values when checking the unique contstraint

I can clearly see in the dataset the string has spaces on the end. I know this is the exact problem because if I append a letter after one of them the exception goes away

Why does it trim the string when validating the Primary Key unique constraint

Thanks
Jeff
 
ansi sql ignores trailing blanks on string compares



Jeff Flowerday said:
I'm loading a key values into a database and two may be identical except
for maybe 1 or 2 trailing spaces. This causes a unique constraint error
because for some reason it's trimming the string values when checking the
unique contstraint.
I can clearly see in the dataset the string has spaces on the end. I
know this is the exact problem because if I append a letter after one of
them the exception goes away.
 
I understand that ANSI SQL ignores trailing blanks. Does that mean in an ADO.NET dataset that a Primary Key on a datatable is going to do the same and how to make it not do that? The data is original coming from Oracle and it allows for trailing spaces and considers it unique

Thanks
Jeff
 
Back
Top