Link to home
Start Free TrialLog in
Avatar of b001
b001Flag for Afghanistan

asked on

read data from dbf file

Hi Experts
I have been having problem where files are left open and on shutdown it corrupts the file.
is there a way to open c connection  to dbf table and read the data like in .net   So that as soon as you read the data you can close the connection?

thanks
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

.NET does not really connect and disconnect from DBFs, it's just working through either ODBC Driver or OLEDB PRovider and these do the usual native access of DBF files as you do in VFP. Just because you have to open a connection with an OLEDB connection string or a DSN in .NET doesn't make DBFs connected or disconnected and working with a server, this is just the ODBC/OLEDB nomenclature.

Bye, Olaf.
Avatar of b001

ASKER

HI Olaf
What I am trying to achieve  is that no table is left in use in case there is power cut and the files get corrupted. Please advice what is the best way to stop getting files corrupted.
-USV to prevent power outages, so you only need to deal with users shutting down windows.
-ON SHUTDOWN rect with not allowing Windows to shutdown
-Turn off oplocks (turn off smb2 protocol to be able to turn off oplocks)
-Not using DBFs at all
-....

It's very unlikely you get corruptions just because windows shuts down. You have to write during the shutdown to corrupt files. File corruptions only occur at writing. In case of power outages nothing happens to a file just because it is open.

Bye, Olaf.
Olaf is correct. The DBF file cannot become corrupted without writing to it. If this really happens to you then you should look at your hardware reliability.

OK, let suppose you are writing to the DBF file from .NET

To minimize the damage possibility you have to close the connection or the file whenever it is not used. You may also execute the FLUSH or FLUSH FORCE command which writes all changes to the disk so the failure or user stupidity cannot corrupt data in buffers.

You should disclose how do you access DBF files then we may tell more.

BTW, DBF files on our server accessed by several hundred users every day were not corrupted for years. The point is the stable environment and no direct network access to DBFs. Interesting is the fact data are not damaged even when we kill all instances accessing them... The reason could be VFP transactions which are minimizing the disk access.
Avatar of b001

ASKER

I have not had this problem for a long time. It has happened twice in last 2 weeks only on one machine that is running windows8 and it corrupted the same table. Could there be an reason for this to happen?
ASKER CERTIFIED SOLUTION
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

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