Click here to Skip to main content
15,881,866 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can i use "like" in datatable.select metheod in C#10?
e.g : datatable1.select("name like 'A__Z'") for records that have 4 lenght size and start with "A" and ends with "Z" ?
thanks.
Posted

if you considered .Net framework 1.0 or 1.1 instead of "C#10", you should upgrade to .Net framework 2 or later and use Linq to SQL.

Please find difference between .Net Framework 1.1 , 2.0 , 3.5

From C# 2.0 to 4.0

example of :
C#
from u in datatable1
where 
    u.name.Length == 4 &&
    u.name.StartsWith("A") &&
    u.name.EndsWith("Z")
select u
 
Share this answer
 
v3
Comments
javad naroogha 4-Dec-12 3:19am    
thanks
Mohamed Mitwalli 4-Dec-12 6:09am    
+5
Try
C#
datatable1.Select("Name LIKE 'A%' AND Name LIKE '%Z' AND LEN(Name) = 4");
 
Share this answer
 
Comments
javad naroogha 4-Dec-12 3:19am    
thanks
Mohamed Mitwalli 4-Dec-12 6:09am    
5+
__TR__ 7-Dec-12 11:38am    
Thank you :)
That is going to take either LINQ or RegEx.
 
Share this answer
 
Comments
javad naroogha 4-Dec-12 2:26am    
thanks,I don't use LINQ.
MT_ 4-Dec-12 2:26am    
This is at the most can be a comment and not solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900