Non breaking spaces(160) instead of spaces (32) in tableadapter of strongly typed dataset

364 views Asked by At

I can not understand why it is replaced a simple space in a field of a sql server table with a non-breaking space. I have a dataset, that was made with the Visual C# Designer, that read data from a sql server table, and when a field has a many spaces (ascii 32) replace with nonbreaking spaces (160).

From Dataset: X_--/----XXX/X/_-

From Sql Server: X___/_____XXX/X_/__

"_" is a simple space (32)

"-" is a non breaking space.

Can anyone help me?

Maybe it is something related with Locale / CultureInfo? I tried but without success ...

I have searched and there is a lot of information about how to replace nbsp but I only need to recover the data from sql server in the way how it is on it, with spaces (ascii 32). It is very important to me because this field is a primary key and it is not working the relation with another table.

Thanks in advance. Jorge.

I want to add 2 testing what I have just made.

1- When I use line code to get data from the sql server table, I get the same error:

        string query = "SELECT * FROM Repuestos where repuestoid < 40000";
    using (SqlConnection sqlConn = new SqlConnection("Data Source=127.0.0.1;UID=sa;PWD=xxxx;DATABASE=Base;"))
    using (SqlCommand cmd = new SqlCommand(query, sqlConn))
    {
        sqlConn.Open();
        dt.Load(cmd.ExecuteReader());
    }
    dataGridView1.DataSource = dt;

2- And this is the more important, when I do these things in another machine I get the code in correct way. It seems that something with the computer is causing this.

Computer with error: Windows XP SP3, Visual Express C# 2008, Language Spanish Computer Ok: Windows 7 Home Edition SP1, Visual Express C# 2008, Language English

Please anyone can help me? Thanks!

0

There are 0 answers