I am importing excel sheet to DataTable using oledb connection as below.
private static DataTable UploadExcelSheet(string fileName)
{
DataTable u
How about filtering the rows after the query has executed using Linq to object:
var filteredRows = uploadDataTable.Rows.Cast<DataRow>().Where(
row => row.ItemArray.Any(field => !(field is System.DBNull)));
Expanding on the previous answers, this worked for me. Delete rows where all fields are null.
Dim deleteRows = From row In result.AsEnumerable
Where row.ItemArray.All(Function(field) Equals(field, DBNull.Value))
For Each deleteRow In deleteRows
deleteRow.Delete()
Next
Expanding on vc's answer, this will remove all rows that which each of it's columns contain either nothing or white space:
dataTable = dataTable.Rows.Cast<DataRow>().Where(row => !row.ItemArray.All(field => field is System.DBNull || string.Compare((field as string).Trim(), string.Empty) == 0)).CopyToDataTable();
Use
".. WHERE NOT ([Lastname] = '' OR [DOB*] IS NULL OR ... )