BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

I/O error 103
Goto page 1, 2  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
John Luetich
Guest





PostPosted: Fri Mar 03, 2006 5:03 pm    Post subject: I/O error 103 Reply with quote



I have a database app shared by about 10 people.

I create a report in a text file, copying fields into strings and writeln
the strings, and open the text file in Word. Each text file has a different
filename. Yet if one user has one file open in Word, and another tries to
open another, they get an I/O Error 103.

Is there a way to correct this?

Thanks

Back to top
John Herbster
Guest





PostPosted: Fri Mar 03, 2006 5:03 pm    Post subject: Re: I/O error 103 Reply with quote



"John Luetich" <jluetich (AT) scaoig (DOT) org> wrote
Quote:
I have a database app shared by about 10 people.
I create a report in a text file, copying fields into
strings and writeln the strings, and open the text
file in Word.

Each text file has a different filename.

I can believe that. <g>

Quote:
Yet if one user has one file open in Word, and another tries to open
another,

Another? Has the writer close the file?

Quote:
they get an I/O Error 103.

To find more info on the subject error:
http://groups.google.com/groups?as_epq=I%2FO+error+103&as_oq=&as_ugroup=borland.public.delphi.*

HTH, JohnH

PS: Maybe it is time to learn about classic databases.
Back to top
John Luetich
Guest





PostPosted: Fri Mar 03, 2006 5:03 pm    Post subject: Re: I/O error 103 Reply with quote

I didn't appreciate the PS

More explicitly, I have a table with a number that gets incremented every
time a text file report is generated (the number goes into the filename), so
the names are unique, and yet sometimes, not always, I/O 103 appears.

Any ideas, from a classic point of view?




"John Herbster" <herb-sci1_at_sbcglobal.net> wrote in message
news:440866b7 (AT) newsgroups (DOT) borland.com...
Quote:

"John Luetich" <jluetich (AT) scaoig (DOT) org> wrote
I have a database app shared by about 10 people.
I create a report in a text file, copying fields into
strings and writeln the strings, and open the text
file in Word.

Each text file has a different filename.

I can believe that. <g

Yet if one user has one file open in Word, and another tries to open
another,

Another? Has the writer close the file?

they get an I/O Error 103.

To find more info on the subject error:
http://groups.google.com/groups?as_epq=I%2FO+error+103&as_oq=&as_ugroup=borland.public.delphi.*

HTH, JohnH

PS: Maybe it is time to learn about classic databases.




Back to top
John Herbster
Guest





PostPosted: Fri Mar 03, 2006 5:03 pm    Post subject: Re: I/O error 103 Reply with quote

"John Luetich" <jluetich (AT) scaoig (DOT) org> wrote
Quote:
More explicitly, I have a table with a number that gets incremented every
time a text file report is generated (the number goes into the filename),
so the names are unique, and yet sometimes, not always, I/O 103 appears.

John L,
What kind of table?
What kind of access to it or database manager?
During what step does the error occur?
Rgds, JohnH
Back to top
Bill Todd
Guest





PostPosted: Fri Mar 03, 2006 5:03 pm    Post subject: Re: I/O error 103 Reply with quote

Are you getting an error when you open the file?

Do you have file I/O exceptions enabled with {$I+}?

Do you know what statement causes the error?

This may be a timing error if your code creates the file and tries to
open it immediately thereafter. You might try adding a time delay
between creating and opening the file.

--
Bill Todd (TeamB)
Back to top
John Luetich
Guest





PostPosted: Fri Mar 03, 2006 6:03 pm    Post subject: Re: I/O error 103 Reply with quote

I suspect closefile is the culprit.

103 File not open Reported by CloseFile, Read Write, Seek, Eof, FilePos,
FileSize, Flush, BlockRead, or BlockWrite if the file is not open.



"John Herbster" <herb-sci1_at_sbcglobal.net> wrote in message
news:4408789d (AT) newsgroups (DOT) borland.com...
Quote:
If I get 103 in Word, I also get it in Wordpad.

John L,
Then, I don't think that your error has anything to do with
databases. Have you looked up meaning of error 103 yet?
--JohnH

Back to top
John Herbster
Guest





PostPosted: Fri Mar 03, 2006 6:03 pm    Post subject: Re: I/O error 103 Reply with quote

Quote:
If I get 103 in Word, I also get it in Wordpad.

John L,
Then, I don't think that your error has anything to do with
databases. Have you looked up meaning of error 103 yet?
--JohnH
Back to top
John Luetich
Guest





PostPosted: Fri Mar 03, 2006 6:03 pm    Post subject: Re: I/O error 103 Reply with quote

More info:

I added a second button executing the same report, but bringing it up in
Wordpad.

If I get 103 in Word, I also get it in Wordpad.

I'll try the time delay.

Thanks


Quote:
Do you know what statement causes the error?

This may be a timing error if your code creates the file and tries to
open it immediately thereafter. You might try adding a time delay
between creating and opening the file.

--
Bill Todd (TeamB)
Back to top
John Luetich
Guest





PostPosted: Fri Mar 03, 2006 6:03 pm    Post subject: Re: I/O error 103 Reply with quote

Here's my code. the tables are Paradox but I don't think it makes any
difference

with tblzprntid do begin
tmpprnt1 := fieldbyname('prntID').asInteger;
tmpprnt2 := tmpprnt1 + 1;
edit;
fieldbyname('prntID').asInteger := tmpprnt2;
post;
end;

stprntID := inttostr(tmpprnt2);
stpath2 := 'h:\hidedocs\p' + stprntID + '.txt';
Assignfile(f,stpath2);
Rewrite(f);
writeln(f,'
' + sttoday2);

....................
finally
Flush(f);
closefile(f);
end;
stpath1 := 'C:\Program Files\microsoft office\office10\winword.exe' + ' ' +
stpath2;
try
pc := stralloc(length(stpath1)+1);
StrPCopy(pc,stpath1);
iError := WinExec(pc,SW_SHOWNORMAL);
if iError < 32 then
ShowMessage('Error # ' + IntToStr(iError) +
' occurred.');
finally
StrDispose(pc)
end;



"Bill Todd" <no (AT) no (DOT) com> wrote in message
news:44086fda$1 (AT) newsgroups (DOT) borland.com...
Quote:
Are you getting an error when you open the file?

Do you have file I/O exceptions enabled with {$I+}?

Do you know what statement causes the error?

This may be a timing error if your code creates the file and tries to
open it immediately thereafter. You might try adding a time delay
between creating and opening the file.

--
Bill Todd (TeamB)
Back to top
Bill Todd
Guest





PostPosted: Fri Mar 03, 2006 7:03 pm    Post subject: Re: I/O error 103 Reply with quote

John Luetich wrote:

Quote:
I suspect closefile is the culprit.

I cannot see how that is possible since your code writes to the file
immediately before closing it. The file must be open or the write would
have failed. The write could be causing the error if there was a
problem opening the file. What is the complete text of the error
message that you get? Are you getting an EInOutError exception?

--
Bill Todd (TeamB)
Back to top
John Luetich
Guest





PostPosted: Fri Mar 03, 2006 7:03 pm    Post subject: Re: I/O error 103 Reply with quote

It's a very small dialog box with the app name on the banner, below a red
M&M with an X on it , and the text only says "I/O Error 103"

How do I insert a delay? I've looked at the WAIT statements and they're not
what I want. I remember a parameter for seconds.

Thanks
John




"Bill Todd" <no (AT) no (DOT) com> wrote in message
news:4408819b$1 (AT) newsgroups (DOT) borland.com...
Quote:
John Luetich wrote:

I suspect closefile is the culprit.

I cannot see how that is possible since your code writes to the file
immediately before closing it. The file must be open or the write would
have failed. The write could be causing the error if there was a
problem opening the file. What is the complete text of the error
message that you get? Are you getting an EInOutError exception?

--
Bill Todd (TeamB)
Back to top
Bill Todd
Guest





PostPosted: Fri Mar 03, 2006 7:03 pm    Post subject: Re: I/O error 103 Reply with quote

John Luetich wrote:

Quote:
How do I insert a delay? I've looked at the WAIT statements and
they're not what I want. I remember a parameter for seconds.

See the Sleep procedure in the on-line help. I hope that works because
I am out of ideas.

--
Bill Todd (TeamB)
Back to top
John Herbster
Guest





PostPosted: Fri Mar 03, 2006 7:03 pm    Post subject: Re: I/O error 103 Reply with quote

Bill and John L,
The following code executes without problem under WinXP SP2.
Rgds, JohnH

Var FNbr: integer;

Procedure TForm1.Button5Click(Sender: TObject);
var F: TextFile; stpath1, stpath2: string; iError: integer;
begin
Inc(FNbr);
stPath2 := Format('C:\Temp\Temp%3.3D.TXT',[FNbr]);
AssignFile(F,stpath2);
ReWrite(F);
WriteLn(F,'File Path = ' + stPath2);
// Flush(F); The flush is not required. The close will do it.
CloseFile(F);
stpath1 := 'C:\Program Files\Microsoft Office\Office10\winword.exe'
+ ' ' + stpath2;
iError := WinExec(PChar(stPath1),SW_SHOWNORMAL);
if iError < 32
then ShowMessage('Error # ' + IntToStr(iError) + ' occurred.');
end;
Back to top
John Herbster
Guest





PostPosted: Fri Mar 03, 2006 9:03 pm    Post subject: Re: I/O error 103 Reply with quote

Here is aA little variation on the previous. If a file with
the same name is open by WinWord, then the ReWrite
causes the error
"I/O error 32 trying to open C:\Temp\Temp001.TXT".
to pop into the memo box.

Var
FNbr: integer;
Const
EditorPgmPath =
'C:\Program Files\Microsoft Office\Office10\winword.exe';
procedure TForm1.Button5Click(Sender: TObject);
var F: TextFile; stpath1, stpath2: string; iError: integer;
begin
Inc(FNbr);
stPath2 := Format('C:\Temp\Temp%3.3D.TXT',[FNbr]);
AssignFile(F,stpath2);
{$I-}
ReWrite(F);
iError := IoResult;
{$I+}
If iError <> 0
then Memo1.Lines.Add(Format
('I/O error %D tring to open %S.',[iError,stPath2]))
// Ex: I/O error 32 trying to open C:\Temp\Temp002.TXT
// Using "C:\>net helpmsg 32" gives
// "The process cannot access the file because it is being
// used by another process."
else
try{finally}
WriteLn(F,'File Path = ' + stPath2);
finally
CloseFile(F);
stpath1 := EditorPgmPath + ' ' + stpath2;
iError := WinExec(PChar(stPath1),SW_SHOWNORMAL);
if iError < 32
then Memo1.Lines.
Add(Format('iError=#%D occurred.',[iError]));
end{finally};
end;
Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Fri Mar 03, 2006 10:03 pm    Post subject: Re: I/O error 103 Reply with quote

John Luetich wrote:
Quote:
Here's my code. the tables are Paradox but I don't think it makes any
difference

with tblzprntid do begin
tmpprnt1 := fieldbyname('prntID').asInteger;
tmpprnt2 := tmpprnt1 + 1;
edit;
fieldbyname('prntID').asInteger := tmpprnt2;
post;
end;

With this code it is very possible for two computers (or even more) to get
the same number and this would easily explain the error you are seeing.

- Any number of computers could read the current value from the table before
any have incremented and written back the new value.
- therefore any number can end up writing back the same new value and
attempting to use this to write the text file.
- whoever launches Word first wins.

Sticking with Paradox, you need to set Exclusive to true on the TTable and
add calls to Open and Close the table in the above code. Wrap that in a
try/except block and, in the case of an exception, wait a bit and try again.

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"Democracy, without the guarantee of liberty, is merely a method of
selecting tyrants." - Alan Nitikman
Back to top
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
 


Powered by phpBB © 2001, 2006 phpBB Group
.