Re:newbie question about putting file into a db table
If you are using ADO components (ADOExpress, Delphi 5) or a MS Access
database (using BDE MSACCESS or ODBC) you can do what you always have done.
If you are using another database type you have to manually import the data,
e.g.:
var
F: TextFile;
Line: String;
Fields: TStrings;
i, n: Integer;
begin
AssignFile(F, 'filename.csv');
FileMode := 0;
Reset(F);
try
Table1.EmptyTable;
Fields := TStringList.Create;
try
while not EOF(F) do
begin
ReadLn(F, Line);
Fields.CommaText := Line;
n := Table1.FieldCount;
if n > Fields.Count then
n := Fields.Count;
Table1.Edit;
try
for i := 0 to n - 1 do
Table1.Fields[i].AsString := Fields[i];
Table1.Post;
except
Table1.Cancel;
end;
end;
finally
Fields.Free;
end;
finally
CloseFile(F);
end;
end;
"rut" <r...@eal.com> schreef in bericht
news:57Yk5.1216$IH.40928@newsread2.prod.itd.earthlink.net...
Quote
> I have a tab delimited file that I need to turn into a temporary table so
I
> can compare this table's fields to a table in a SQL database.
> I'm use to VB and ADO where I could easily build a table in memory right
> from the file.
> Is there an easy way to do this in Delphi(5) Pro version? The table has
the
> potential to be very large. ie 2-300,000 records.