I have a DataTable with a column named “Insurance ID”. I don’t have any control over how I am getting this data. I want to select a particular row but the DataTable.Select method fails because there is a space in the column name.
I have tried:
1) string expr= “Insurance ID = ‘1’”
2) string expr=“‘Insurance ID‘ = ‘1’”
3) string expr=“\”Insurance ID\” = ‘1’”
used with the following:
DataRow [] oaDR = myDataTable.Select(expr);
1 and 3 fail with an exception. 2 runs but nothing is found.
After some research I solved the issue using
string expr=”[Insurance ID]=’1′”
DataRow [] dRow = myDataTable.Select(expr);
It worked like a charm.
Thanks,
This has been very helpful.
Thanks, worked like a charm!
I looked far and wide for this solution!
in C#, you can just use something like:
string sql = “SELECT [Network Name] FROM Info where [Network Name] LIKE ‘%Comp1%'”;
Thanks this is really helpful.
I mentioned your blog in my blog post
http://techstarvation.wordpress.com/2012/03/30/selecting-rows-from-datatable-by-applying-length-filter/
Thanks for sharing
Thanks
Thanks so much for posting this, this was driving me CRAZY!
Dude You Just Saved me a hell of a lot Research… Thanks a Bunch…
Nice