Link to home
Start Free TrialLog in
Avatar of miauw
miauwFlag for Netherlands

asked on

empty Paradox db

I like to know how to empty a Paradox db without
a iteration in Delphi 3.0, sometime like table1.DELETEALL

Thanks
Avatar of kjteng
kjteng

table1.emptyTable
Avatar of miauw

ASKER

Well ofcourse I tried that but, when
I replace my code (which works):
------
while not(HTML.EOF) do
begin  HTML.First; HTML.Edit; HTML.Delete; HTML.Next;end;
 HTML.First; HTML.Edit; HTML.Delete;
------

with HTML.EmptyTable
I get:
Project THIS.exe raised exception class EDBEngineError with
message 'Table cannot be opened for exclusive use.'. Process stopped
Use Step or Run to continue.

The result I get when I use:
HTML.First; HTML.Edit; HTML.emptytable

My program run locally. There are no other users/other programs involded.
with Table1 do
begin
  Close;
  Exclusive:=True;
  EmptyTable;
  Exclusive;=False;
  Open;
end;
Avatar of miauw

ASKER

Thanks Ronit, but :

When I replace  
Exclusive;=False with Exclusieve:= False
then still I get an error:

Project THIS.exe raised exception class EDBEngineError with
 message 'Table is busy.
Table: F:\BLA\BLA.DB
User: MyWin95ComputerName
Process stopped   Use Step or Run to continue.
Avatar of miauw

ASKER

I mean
Exclusive:=False;
If you have multiple TTables pointing to the same Paradox table, you'll have to close them all before setting Exclusive := true
Avatar of miauw

ASKER

There is just one TTable... there is just one TDataSource..
BlackMan is correct, All tables component that point to the same physical table must be closed before changing the exclusive status.
Exclusive:=True means you can only open one "session" of that particular table.
Set the exclusive property in object inspector to false.
otherwise the ide will have the exclusive rights on the file.
Avatar of miauw

ASKER

To Ronit: as I wrote there is just 1 table involded in the entire program.
.
Is another application opened this table, like the Database DeskTop?
You should close the table also in the othe applications.
Avatar of miauw

ASKER

I can not change the properties of Exclusive in the Object Expector either.
When I put Active to false, then Exclusive to true, then Active to true:
I get a 'Table busy' either. The program isn't active then (I mean, I didn't
press Run).

When I set Active to False, quit Delphi
and then set  Exclusive to true, Active to False,
I don't get an errormessage right away...
but when press RUN I get:
...same exception class as above...
'File is locked'


Avatar of miauw

ASKER

Sorry I ment.

When I set active to False, quit Delphi, exclusive to True, active to True...
Avatar of miauw

ASKER

Again for clarity:
No other program is running accept Delphi.
e.g. Database Desktop is not running.

1. Exit Delphi.
2. Delete the file Pdoxusrs.net, usually located in c:\.
3. Reload Delphi and run your program.( the Pdoxusrs.net will be recreated).
Is it OK now?
Is you file stored on lan server. If so may be your pdoxusrs.lck and parodox.lck file is not updated.
Avatar of miauw

ASKER

To Kjteng: no it is not on a lan server. I checked too if
 pdoxusrs.lck and parodox.lck were present on my HD's: NO.

To RoNit
C:\ contained PDOXUSRS.NET . I renamed it.

this is sequential:

Attempt 1:
Quit Delphi, rename C:\PDOXUSRS.NET to garbage.txt
Started Delphi.
Table1 Object Inspector: Exclusive: NO Active Yes
Pressed Run:  'Table is busy error''
After this C:\ contained PDOXUSRS.NET .

Attempt 2:
Quit Delphi. Set Active to No,
Set Exclusive to Yes. Set Active to Yes:
No error message this time (see above) at the point
of changing Set Active to Yes.
When I pressed Run I got the error: ....File is locked..
Run or Step to continu.

Attempt 3:
Set Active to No (exclusive was set to Yes remember).
Quit Delphi, rename C:\PDOXUSRS.NET to garbage.txt
Started Delphi. Set Active to yes  (exclusive was set to Yes remember)
same error as in attempt 2. (....File is locked..)

I am getting very depressed right now,
remember that the slow iteration:
while not(HTML.EOF) do
       begin  HTML.First; HTML.Edit; HTML.Delete; HTML.Next;end;
        HTML.First; HTML.Edit; HTML.Delete;
still DOES WORK perfectly.

Please give me accept guideliness as to do what in which order,
I am loosing hours here. I will raise the point by 200.









Let's go step by step:
1. This is from Delphi Help File:

Use Exclusive to prevent other applications from accessing a Paradox or dBASE table while this application is using it. Before opening the table, set Exclusive to True.
When Exclusive is True, then when the application successfully opens the table, no other application can access it. If the table for which the application has requested exclusive access is already in use by another application, an exception is raised. To handle such exceptions, write an exception handler.

A table must be closed before changing the setting of the Exclusive property. Do not set Exclusive to True at design time if you also intend to set the Active property to True at design time. In this case an exception is raised because the table is already in use by the IDE.

2. Delete again PDOXUSRS.NET.
3. Restart Windows.
4. Create a new clean application and post a TTable on the from.
5. Set the following properties at design:
    Exclusive:=False;
    Active:=True;
6. Place a button and write the OnClick event:
with Table1 do
     begin
       Close;
       Exclusive:=True;
       EmptyTable;
       Exclusive;=False;
       Open;
     end;
7. activate the application and press the button to empty the table.
If this does not work, then send me the project and the table by EMail, and I'll check it.

No. DON'T set the active in object inspector to True.

set active to false,
write code to set table1.active to true in your program
save the project, quit delphi;
delete C:\PDOXUSRS.NET;
start delphi again
run

alternatively, quit delphi, run you exe from windows without IDE.
S/He can set the Active to True as long as the exclusive is false.
Avatar of miauw

ASKER

Thanks, I will try both. Soon.
I have only 1 request:

 >  Create a new clean application and post a TTable on the from.

NO! The point being I must get this app. to run, not a brand
new one.
agreed.
The thing is getting strange... may be s/he need a rest.
Who needs a rest?
miauw  ... I also have been in such situtation before and usually i found my mistake after taking a nap

In these cases I usually use the Elimination Method.
The reason I want to see if it works on a clean application is to verify that you are writing the right code and that the BDE files work OK.
Avatar of miauw

ASKER

Thanks for your advise Kjteng, but let us discuss my Delphi program here
and not the way I spend my time
.
I have followed Ronit instructions:
1- I deleted c:\pdoxusrs.net (the only pdoxusrs.net on my HD)
2- I restarted Windows
3- I put a table on the form, first setting active to false (and exclusive to false).
4- I inserted the code
with Table1 do
            begin
              Close;
              Exclusive:=True;
              EmptyTable;
              Exclusive:=False;
              Open;
            end;
in a button.OnClick procedure and table1 being the same as
in the program which all this is ment for.

5- Ran the program: no errors.

6- Now I changed with the Object Inspector the table prop Active to True as RonIt
    suggested:

Again ERROR: the table is busy.

7- I ran the program .EXE from the Explorer. No errors at all.


I had once also this problem with a paradox database. When I restarted WINDOWS the problem was solved. Another time I just removed the database and rewrote the table. This worked too. I don't know where the problem came from, but they usely appear when something goes wrong testing it. And then I think the paradox tables aren't closed correctly.
OK, I have checked it and the Active=True in the design time causes the problem although it shoudn't, therefore if you want to see the Table records prior to deleting it, write:
procedure TForm1.FormCreate(Sender: TObject);
begin
  table1.Open;
end;

5- Ran the program: no errors ...  You mean the table is empty now? And the error message only come out when you try to set the active property at design time?  
I tried  on my pc those steps you have done. No error.
However I am using D1.
Let me go home to try on another pc which have d3 installed in it.
You may also send you code to me at gjdeng@yahoo.com

Bye
Avatar of miauw

ASKER

The problem is solved now.

The Delphi Programming environment gives the problem.

I set active to false, and in form.show set it to true : again an error.

Then as suggested by Zipnab, I booted Win again, and after that it worked
but with only active set to false....

The setting of Exclusive didn't matter at all, both true and false = ok. The existence
of c:\pdoxusrs.net was irrelevant too, in this case.

In all onesty I think Kjteng gave me the best clue how to solve
the problem, but after I solved the problem myself I red RonIt last comment,
which is to the point.
So either Kjteng or RonIt submit your comment as a answer, so this
question can be closed.



ASKER CERTIFIED SOLUTION
Avatar of ronit051397
ronit051397

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi miauw, I fully agree with your comment. Have a nice day. c.u. ZiF.