Problems with FindLast command.



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

.



Relevant Pages

  • Re: Bad Linux Programmers
    ... if the programmer had any real clue as to how his ... busy signal. ... rant wondering why the error message couldn't say "line busy" instead ... but is by no means the *only* reason. ...
    (comp.os.linux.misc)
  • Re: Strings start at index 1, Dynamic Arrays at index 0, Pchars start at index 0
    ... >>Suppose a programmer wants to get the first character of a string via a ... >>Next he wants the first character of an edit box. ... That's totally inconsistent. ... Normally one gets no error message because it starts at zero, ...
    (alt.comp.lang.borland-delphi)
  • Re: [Info-ingres] Is there a QUEL error messages and codes manual ?
    ... This looks like it's probably DELETED_TID returned from the query optimizer indicating that a record or tuple has been deleted and the TID is thus stale - does that fit the logic? ... programmer did not code the program to write the error message along ...
    (comp.databases.ingres)
  • Re: Do we always have to update or insert? Why cant we just relate?
    ... > the database) is the same, but the error message gives a bit more ... there is a data area where such things as a row count are normally included. ... The programmer has the information that nothing went wrong, ... Been a long time since I accessed SQL from a program. ...
    (comp.databases.theory)