Member Avatar


I was just playing around with using a linq query on a dataTable that has information from sql. I was using

var q = from Email in dtEmail.AsEnumerable()
                                where Email.Field<string>("Email") == "yay"
                                select Email;

But for some reason it will not query the email datatable. And yes, I actually did put yay in one of the cells if anyone is wondering. (like I said, I'm just playing around with it) When I pull the ID of one and set it to an int in the query, it pulls just fine, but whenever I try a string, it doesn't pull anything. Does anyone know what might be causing this?

Recommended Answers

All 2 Replies

Is the datatype property of that column set?

Member Avatar

Yes, it is set to an nvarchar but it still will not detect the column for some reason.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.