SELECT with either 2 values

Code: dt.Select(“Username LIKE '”+username+“’ AND Description like ‘Unsuccessful attempt to login by user’ OR ‘User Limit Reached’”).copytodatatable
I want to select rows that contains these values: ‘Unsuccessful attempt to login by user’, ‘User Limit Reached’’

My code has no error but it doesn’t work. Is there a way?

Thank you xoxo

I was facing the same issue, I mean copytodatatable was not working as it supposed to be in C#. I solved it using this method:

datarow[] rowValues = dt.Select(“Username LIKE '”+username+"’ AND Description like ‘Unsuccessful attempt to login by user’ OR ‘User Limit Reached’");

datatable new_dt = dt.Clone();

foreach datarow row in rowValues { new_dt.Add(row.ItemArray); }

Below is the screenshot to achieve it:

Use percentage symbol before and after the search string.

dt.Select(“Username LIKE '%”+username+“%’ AND Description like ‘%Unsuccessful attempt to login by user%’ OR ‘%User Limit Reached%’”).copytodatatable

Hi, it is not about the *.

This code works:
dt.Select(“Username LIKE '”+username+“’ AND Description like ‘Unsuccessful attempt to login by user’”).Length > 0

But how to write if the description column can either have value A or value B in that code?

Thank you for help. It was useful.

However, my .copytodatatable works as I amended the xaml file so that is not the problem here

Good to know :slight_smile:

dt.Select(“Username LIKE '%”+username+“%’ AND Description like ‘%Unsuccessful attempt to login by user%’ OR ‘%User Limit Reached%’”).copytodatatable

@palindrome :slight_smile:

how do I select the dt opposite of the query? E.g. i want the dt to select rows that doesn’t match to above conditions

Try this <>

How do i use it in that code?

abc.Select(“[Column1] <> ‘text’”)

@palindrome sorry, pls elaborate what will that do?

dt.Select(“Username LIKE '%”+username+“%’ AND Description not like ‘%Unsuccessful attempt to login by user%’ OR ‘%User Limit Reached%’”).

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.