Strange Control Characters in C# DataTable results, not in SSMS or VB.NET results

251 views Asked by At

I have a sql query, select distinct(name) from customers with (nolock) and it returns the text I want in SSMS, ie "Smith, John", etc.

However, when I get the string value from my DataTable in C#, I get back strange Control Characters at the beginning of my string, like \u001f\u001f\u001fSmith, John

enter image description here

Where is this coming from? Is it bad data in my database, or am I missing some steps related to character encoding or collation?

If anything culture or collation-related needs to be done, I'd prefer to do it from either from within the SQL query (without introducting a new SQL function) or from C#, since I can't control what values are placed in the database, I can only read from them.

UPDATE:

I have another VB.NET application which queries these names for a different purpose. This other program does NOT return the printing control characters in the DataTable. This leads me to believe there is something wrong with my SQLAdapter or SQLCommand implementation. Any ideas?

The table collation is SQL_Latin1_General_CP1_CI_AS.

0

There are 0 answers