Forum > Databases
Tdbf and network :(
(1/1)
Fossy:
Hello:
I'm using Tdbf (Dbase III, level 3) with exclusive=false property, but when I access to DBF in the network, the application says "Exclusive access is required for this operation" and exit.
In local mode (for test the same), I run the application and runs perfectly, but when I run other instance of the same application, I get the same error.
Why?...
Tdbf is not prepared for run in shared mode?, or I'm making something bad?.
Thanks!!!
matthijs:
DBase III is a very old technique and you should not want to use this. It doesnot allow you to share a file. I think you are better of using something like mySQL, Firebird or SQLite.
Fossy:
Here is the error:
socios.FilePathfull:='c:\tecnoasociacion\datos\';
socios.active:=true;
socios.AddIndex('socnum.ndx','N_SOCIO', [ixPrimary]);
socios.OpenIndexFile('socnum.ndx');
socios.IndexFieldNames:='N_SOCIO';
When there one application running with database opened, when we open a new instance of the same application, this ocurrs (debuging):
socios.FilePathfull:='c:\tecnoasociacion\datos\'; ->OK
socios.active:=true; -> OK
socios.AddIndex('socnum.ndx','N_SOCIO', [ixPrimary]); -> FAIL!!!
Message error: "Exclusive access is required for this operation".
Ok..., then I write the next source code in order to open the index file in exclusive mode, but then turn exclusive mode to false for open other instance application:
socios.FilePathfull:='c:\tecnoasociacion\datos\';
socios.active:=true;
socios.exclusive:=true;
socios.AddIndex('socnum.ndx','N_SOCIO', [ixPrimary]);
socios.exclusive:=false;
socios.OpenIndexFile('socnum.ndx');
socios.IndexFieldNames:='N_SOCIO';
This is the result debugging:
socios.FilePathfull:='c:\tecnoasociacion\datos\'; -> OK
socios.active:=true; -> OK
socios.exclusive:=true; -> OK
socios.AddIndex('socnum.ndx','N_SOCIO', [ixPrimary]); ->FAIL!!!!
And I get the same message error.
If I write source code only for open the DBF file (without indexes), the application running PERFECTLY! in network with database shared.
Is this a bug?, or there any other form for open indexes without that error?.
Thanks!!
matthijs:
Have you tried setting exclusive before opening the table? Sharing a database and opening it exclusive are things which are not compatible. It looks like you need to have a table opened exclusive before you can use an index. As one user most probably needs another index then the next user, it makes DBIII not suitable for the job.
If you were using Delphi I would advise you to use clientdataset, because they have their own sorting and indexing functionality, so you will not need the DBIII index-files. I do not know if the clientdataset has already been implemented for lazarus.
Fossy:
Hello matthijs:
Thanks for your reply.
My application is now full working in network with Dbase III files. The problem was in the AddIndex (is for add/create new indexes what not exists), then, only is needed to open the index files (without add):
socios.FilePathfull:='c:\tecnoasociacion\datos\';
socios.active:=true;
socios.OpenIndexFile('socnum.ndx');
socios.IndexName:='socnum.ndx'; -> Set index by name file
And you can work in network with all application instances what you need :).
The problem is what not there any manual of TDBF. I only guides by short manual stored in WIKI and I was confused with AddIndex, but DBF files is very very robust databases for working in network (of all life).
Navigation
[0] Message Index