Ignore case while searching the data table

Hi All,

I have the following statement

SystemUsersDt.Select(“[NAME]='”+varName+“'”).CopyToDataTable

vanName is "VINNIE’

But the actual mame in the data table I am searching can come in any format - For eg: Vinnie or vinnie or VINNIE or VinnIE or viNNIE etc

How can I ignore case in the data table?

Hi @Krithi1 try below Linq Query

SystemUsersDt.AsEnumerable().
Where(Function(row) row.Field(Of String)(“NAME”).Equals(varName, StringComparison.OrdinalIgnoreCase)).
CopyToDataTable()

Thanks

1 Like

@Akash_Javalekar1
Its giving “zero rows”. I am expecting one row ignoring case.

The actual name is “VINNIE ABC”

Table has the name as “Vinnie ABC”

Hi,

FYI, another approach: DataTable.CaseSensitive property may help you.

dt.CaseSensitive = false

Regards,

@Yoichi

is it working if it has mixed case in the table? Its still not working for me

Yes.

Its still not working for me

There might be difference except case. Can you check both in details? e.g. extra white space etc.

Regards,

@Yoichi

I printed the value and I don’t see any space before or after.

Hi,

For now, can you try to compare both string by the following expression?

String.Join(",",yourString.ToLower().Select(Function(c) AscW(c)))

if there is difference, can you share it?

Regards,

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