string strNewPath = Server.MapPath("~/VendorUploads/" + strusername + ".xls"); strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strNewPath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""; strQuery = "SELECT FROM [Sheet1$]"; oleDbConnection = new OleDbConnection(strConnection); if (oleDbConnection.State == ConnectionState.Closed) oleDbConnection.Open(); oleDbCommand = new OleDbCommand(strQuery, oleDbConnection); oleDbDataAdapter = new OleDbDataAdapter(oleDbCommand); oleDbDataAdapter.Fill(dataTable); 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();
row.ItemArray.All
row.ItemArray.Any
dataTable = dataTable.Rows.Cast<DataRow>().Where(row => !row.ItemArray.Any(field => field is System.DBNull || string.IsNullOrEmpty(field as string))).CopyToDataTable();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)