Hi all,
how can i check if there is at least one row in a datatable with column ID = Myvariable?
For example:
ID First name Last name
1 Alex Uang
2 Mike Rover
And MyVariable is 1 so return True
Thx
Hi all,
how can i check if there is at least one row in a datatable with column ID = Myvariable?
For example:
ID First name Last name
1 Alex Uang
2 Mike Rover
And MyVariable is 1 so return True
Thx
Use below code in if condition,
Datatable.Rows.Count > 0
Thanks @Manish540 but i need to check if in id column table there is the value contained in myVariable
Then pass your datatable to for each row, then inside the for each put a if condition like this,
row(“ID”).tostring.trim.Equals(MyVariable.ToString).
As below screenshot, @andreus91
@andreus91 You can also use this Linq Query inside if Condition :
DT.AsEnumerable.Where(Function(x)x(“ID”).ToString.Equals(yourVariable)).ToArray.Count>0
Thanks a lot! @Manish540 @supermanPunch
The solution in my case is to implement the Linq Query inside if condition.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.