Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to access a locked DBF ?? (Error 3211) 1

Status
Not open for further replies.

MisterC

IS-IT--Management
Apr 19, 2001
501
US
I'm using VB6 and DAO to access a dBase IV table. I keep running into this error:
Code:
3211-The database engine could not lock table 'FINANCE' because it is already in use by another person or process.

I can't stop the external process that is accessing the table, so is there any way around the issue? Can I copy the DBF file or access it outside of DAO?

Thanks for your help!
 

Yes you can copy the file and yes you can access via ADO or even RDO if you wanted but if the other process has it locked you will get the same error.

Where or when do you get this error? On open? Update? Addnew?

 
Thanks for your response.
The error occurs on open. I'm not running any kind of action queries on the data, just a select query.
 

So then you are running, say a Select * query, right? How are you opening the connection/table/recordset? You should be able to specify readonly with forward and backward capabilities if you need them or readonly, forwardonly.

Play around with these settings and I belive you should have some luck.

Good Luck

 
I used to use FoxPro in a previous job, and that makes use of DBF files. It sounds as though someone else has the table opened for exlusive access...

One work around we found was to copy the file, and then blank out the "locked" byte in the file. I think the byte you're after was at an offset of something like 27 or 28 - somewhere in that area...

Try to see if they have more information on DBF files - they might know the correct offset.

mmilan.
 
Here's the code I'm using to access the table. I'm referencing DAO 3.51 in my project. (I've tried DAO 3.6 as well...)

Code:
dim db        as DAO.Database
dim RST       as DAO.Recordset
dim strSQL    as String

Set db = OpenDatabase("C:\SysData", 0, 0, "dBase IV;")
strSQL = "SELECT max(DateValue([keydate])) as MD FROM FINANCE WHERE [RNAME] = 'FinRpt'"
Set RST = db.OpenRecordset(strSQL)

mmilan: yes I believe another process has the table opened for exclusive access - that's what I'm trying to get around. Can I copy the DBF even if it is locked? How would I change the "locked" byte if I did copy the file?

Thanks for your help!
 
You should be able to copy the file ok, so long as there is no access occurring at that particular time. Take the cdx file as well (index).

To change the "locked" byte, open the file for random access with a single byte record length. You should then be able to merely replace the relevent byte with a zero. If you need the specific code to do that, let me know...

mmilan
 
Hmmm... I can't seem to find the "locked" byte in the DBF specification. Also, there are no "CDX" files though I do see some "NDX" files.
 
And attempting to copy the file gives me a "cannot copy..." sharing violation. ARGH!
 

Give this a try...
[tt]
Set db = OpenDatabase("C:\SysData", False, True, "dBase IV;")
[/tt]

Good Luck

 
vb5prgrmr, Thanks for your input - It looks like that may have done the trick!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top