0

If I have a query

var query = from c in ds.Prices
            select c;
dataGridControl1.AutoCreateColumns = true;
dataGridControl1.ItemsSource = query;

datagrid show all data from table(`ds = new DataSet()). But when I add condition

var query = from c in ds.Prices
            where c.idsticker.Equals("GOOG")
            select c;
dataGridControl1.AutoCreateColumns = true;
dataGridControl1.ItemsSource = query;

datagrid is empty. But value GOOG exists in table(idsticker varchar(10) in sql server). When I compare int values(for example condition is where c.prices > 660) it works normal.

What is wrong?

4
  • Have you checked to see if there is a record which has a null idsticker? Or perhaps, the entry with "GOOG" is really "G00G". Commented Jul 7, 2012 at 0:24
  • 1
    You may have hidden character or a space. For a test, copy the text from the field from the database, the one with GOOG. And then do your code comparison. Another method is to use the SQL Manager, and execute a simple query. Commented Jul 7, 2012 at 0:31
  • there are no such records. all records are from .csv file Commented Jul 7, 2012 at 0:32
  • @user1432980, I understand the data may come from csv but when you transfer data from any file to a database, a space may be generated due to quirks in data transfers or buffer copies, like in HTML. Commented Jul 7, 2012 at 0:37

1 Answer 1

2

All I can think of is to apply a Trim() to it, and possibly ToUpper() to see if one or both of those makes any difference.

var query = from c in ds.Prices 
            where c.idsticker.Trim().ToUpper().Equals("GOOG") 
            select c; 
dataGridControl1.AutoCreateColumns = true; 
dataGridControl1.ItemsSource = query; 

Beyond that, try executing the same query using SQL against your database.

select * from prices where idsticker = 'GOOG'
Sign up to request clarification or add additional context in comments.

2 Comments

@user1432980, no, trim itself wasn't the problem, nor additional methods mentioned by Chris. Look what those functions do at least......
I mean problem was with spaces

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.