Null Check in a Data Table

Hello

I need to check whether a DataTable consists of any null Values?

Expected Result: Boolean Value (True or False)
DataTable : We Know only the Name of the DataTable, Say “DT”, NOT Sure How many Columns and NOT Sure How Many rows it has.
Logic to Use : Without Using Loop.

I just wanted to know whether we have any Null Value inside that DataTable or Not.

Thanks in Advance
Dheeraj.

Hi you can use select method and pass the column name if you aware else the column index: like

DataRow rows = DataTable.Select(“[COLUMN 1]=‘’ OR [COLUMN 2]=‘’”);

Hi @Divyashreem thanks for your help.

But I’m not exactly looking for this.
As I specified the requirement : We Know only the Name of the DataTable, Say “DT”, NOT Sure How many Columns and NOT Sure How Many rows and NOT Sure the Names of those Columns. DT is a Dynamic DataTable which will be created according to the Scenario.

Hi @dheeraj_reddy97

Please try this:
“dt1.AsEnumerable().Where(Function(row) row.ItemArray.Any(Function(v) TypeOf v Is DBNull)).ToList().Count()”

Replace dt1 with your datatable. Basically this will return the number rows has null values
Use if condition and see if count is greater than 0 then it has null value.

Regards,
Sasikumar

1 Like

@dheeraj_reddy97

Try something like this.
DT.AsEnumerable().Where(Function(r) r.ItemArray.Any(Function(a) string.IsNullOrEmpty(a.ToString))).Count>0

Should return True of False

2 Likes

Thank you guys @rajeev85 @Sasi.lalo… Its Working!!! :slight_smile:

1 Like

Hi @Divyashreem,
what activity would you use this in ?
Thanks

Hi
Welcome to uipath community
It’s assign activity
@Meadhbh

1 Like

Hi @Palaniyappan,
Thank you for the help!

How to check some of the columns in datatable are null
Any leads on this buddy