I need to import data from Excel into a SQL Server database. I use ADO to read the excel files.
Sometimes it happens that a row is empty in Excel, which will create an empty row import failure on the SQL Server side.
Any good idea to remove these empty rows or detect during import?
I'm looking for a rather effective code style solution, i show my current solution with the field loop here
function EmptyRow(aQuery: TADOQuery): Boolean;
var
i: Integer;
fname: string;
temp_line: string;
begin
temp_line := '';
for i := 0 to aQuery.Fields.Count - 1 do
begin
fname := aQuery.Fields[i].FieldName;
temp_line := temp_line + aQuery.FieldByName(fname).asString;
end;
if (temp_line <> '') then
result := false
else
result := true;
end;