Hello
I am a new programmer in Delphi 6, and I would like to get some assistance with a with the FindLast command.
I am trying to read each record sequentially from a file via ODBC and writing some fields from each record to new
text file sequentially as well.
Each time I run the program it gives the following error message when it reaches the "until not iseof" line.
// ******************* start of error message *******************
Project ScanPal2.exe raises exception class EOleException with message 'Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record'. Process stopped.
// ******************* end of error message *******************
My code is as follows:
// ******************* start of my code *******************
procedure TForm1.OutputFile1Click(Sender: TObject);
var
btnPressed : integer;
FileAttrs : integer;
txt : TextFile;
line : String;
SR : TSearchRec;
iseof : boolean;
begin
if frmSelectDS.cmboxSelDS.Text <> '' then
begin
btnpressed:= MessageDlg('Go ahead and create scanpal import file?', mtConfirmation, mbOKCancel,500);
if btnPressed = mrOk then
begin
qryScanDS.ConnectionString := 'Provider=MSDASQL.1;Persist Security Info=False;Data Source=' + frmSelectDS.cmboxSelDS.Text;
try
begin
qryScanDS.SQL.Text := 'SELECT itemnumber, description1, category, price1, QtyOnHand FROM items';
qryScanDs.Active := true;
//tekst file aanmaken
if FileExists(Options.OutputPath.Text) then
begin
if (MessageDlg('File ' + Options.OutputPath.Text + ' exists. Overwrite?', mtConfirmation,
[mbOk, mbCancel], 0) = mrCancel) then
begin
Exit;
end;
end;
AssignFile(txt, Options.OutputPath.Text);
Rewrite(txt);
repeat
line := qryScanDS.Fields[0].text + Options.SeparationCharacter.Text + qryScanDS.Fields[1].text + Options.SeparationCharacter.Text +
qryScanDS.Fields[2].text + Options.SeparationCharacter.Text + qryScanDS.Fields[3].text + Options.SeparationCharacter.Text +
qryScanDS.Fields[4].text;
if IsDelimiter(Options.SeparationCharacter.Text, line, 0) then
begin
MessageDlg('You must use another character!', mtConfirmation, mbOKCancel,500);
if btnPressed = mrOk then
begin
exit;
end;
end;
WriteLn(txt, line);
iseof := qryScanDS.findnext();
until not iseof
end;
// ******************* end of my code *******************
I hope that someone can point out where my mistake is.
Regards,
Johan
I am a new programmer in Delphi 6, and I would like to get some assistance with a with the FindLast command.
I am trying to read each record sequentially from a file via ODBC and writing some fields from each record to new
text file sequentially as well.
Each time I run the program it gives the following error message when it reaches the "until not iseof" line.
// ******************* start of error message *******************
Project ScanPal2.exe raises exception class EOleException with message 'Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record'. Process stopped.
// ******************* end of error message *******************
My code is as follows:
// ******************* start of my code *******************
procedure TForm1.OutputFile1Click(Sender: TObject);
var
btnPressed : integer;
FileAttrs : integer;
txt : TextFile;
line : String;
SR : TSearchRec;
iseof : boolean;
begin
if frmSelectDS.cmboxSelDS.Text <> '' then
begin
btnpressed:= MessageDlg('Go ahead and create scanpal import file?', mtConfirmation, mbOKCancel,500);
if btnPressed = mrOk then
begin
qryScanDS.ConnectionString := 'Provider=MSDASQL.1;Persist Security Info=False;Data Source=' + frmSelectDS.cmboxSelDS.Text;
try
begin
qryScanDS.SQL.Text := 'SELECT itemnumber, description1, category, price1, QtyOnHand FROM items';
qryScanDs.Active := true;
//tekst file aanmaken
if FileExists(Options.OutputPath.Text) then
begin
if (MessageDlg('File ' + Options.OutputPath.Text + ' exists. Overwrite?', mtConfirmation,
[mbOk, mbCancel], 0) = mrCancel) then
begin
Exit;
end;
end;
AssignFile(txt, Options.OutputPath.Text);
Rewrite(txt);
repeat
line := qryScanDS.Fields[0].text + Options.SeparationCharacter.Text + qryScanDS.Fields[1].text + Options.SeparationCharacter.Text +
qryScanDS.Fields[2].text + Options.SeparationCharacter.Text + qryScanDS.Fields[3].text + Options.SeparationCharacter.Text +
qryScanDS.Fields[4].text;
if IsDelimiter(Options.SeparationCharacter.Text, line, 0) then
begin
MessageDlg('You must use another character!', mtConfirmation, mbOKCancel,500);
if btnPressed = mrOk then
begin
exit;
end;
end;
WriteLn(txt, line);
iseof := qryScanDS.findnext();
until not iseof
end;
// ******************* end of my code *******************
I hope that someone can point out where my mistake is.
Regards,
Johan