How to upload only non-empty rows of Excel spreadsheet using oledb in C#?

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 ... )

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)));

Tags:

C#

Excel

Oledb