主题:求教一个简单的问题
俺是菜鸟,代码如下:
procedure TForm1.Button2Click(Sender: TObject);
Const Space = ' ';
var
i,j : integer;
FF : TextFile;
datapath, path, str : string;
MyLine : String;
begin
path:=ExtractFilePath(Application.ExeName);
ADOTable1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='
+path
+'data.mdb;Persist Security Info=False';
ADOTable1.TableName := '表2';
with ADOTable1 do
begin
Open;
try
OpenDialog1.Title := '请选择要打开的文件';
OpenDialog1.Filter := '数据文件(*.txt)|*.txt';
if OpenDialog1.Execute then
begin
DataPath := OpenDialog1.FileName;
AssignFile(FF, DataPath);
Reset(FF);
try
//for i := 0 to 10 do
while not Eof(FF) do
begin
Application.ProcessMessages;
Readln(FF, str);
MyLine := RegulateStr(str,Space);
Append;
for j:=1 to GetSubStrNum(MyLIne,Space) do
fields[j-1].AsString := GetSubStr(MyLine,Space);
Post;
end; //END while not Eof(FF) do
MessageBox(GetactiveWindow(), '当前数据导入完毕!', '提示',MB_OK + mb_iconexclamation);
except
CloseFile(FF);
end; //END try
end; //END IF
finally
ADOTable1.Close;
end; //END TRY
end; //END with ADOTable1
end;
总指示 while not Eof(FF) do 语句出错!郁闷的很。
procedure TForm1.Button2Click(Sender: TObject);
Const Space = ' ';
var
i,j : integer;
FF : TextFile;
datapath, path, str : string;
MyLine : String;
begin
path:=ExtractFilePath(Application.ExeName);
ADOTable1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='
+path
+'data.mdb;Persist Security Info=False';
ADOTable1.TableName := '表2';
with ADOTable1 do
begin
Open;
try
OpenDialog1.Title := '请选择要打开的文件';
OpenDialog1.Filter := '数据文件(*.txt)|*.txt';
if OpenDialog1.Execute then
begin
DataPath := OpenDialog1.FileName;
AssignFile(FF, DataPath);
Reset(FF);
try
//for i := 0 to 10 do
while not Eof(FF) do
begin
Application.ProcessMessages;
Readln(FF, str);
MyLine := RegulateStr(str,Space);
Append;
for j:=1 to GetSubStrNum(MyLIne,Space) do
fields[j-1].AsString := GetSubStr(MyLine,Space);
Post;
end; //END while not Eof(FF) do
MessageBox(GetactiveWindow(), '当前数据导入完毕!', '提示',MB_OK + mb_iconexclamation);
except
CloseFile(FF);
end; //END try
end; //END IF
finally
ADOTable1.Close;
end; //END TRY
end; //END with ADOTable1
end;
总指示 while not Eof(FF) do 语句出错!郁闷的很。