
VB4,opening database w/o write access to file
Quote:
> I wrote a simple program that just accesses an Access2 db. I don't won't
> anyone to have write access to the files in the directory, they just read
> the data and print a report (
Crystal Report).
> So I only gave them Read and File Scan rights to the directory. But when
> they try to open it (non-exclusive, read-only) it tells me it can't lock
> the file. The only way i've been able to make it work is to give them
> Write access to the file/directory. That defeats the purpose because, if
> they have a db program that can use .mdb files, they can change the data.
> Any ideas? I've been out of programming for awhile, so maybe I'm just
> doing something (else ;) stupid
Why not open the recordset as a snapshot, so that the output is read-only,
but the file itself is not locked? (If you need to protect the file itself,
you could always store it on a secure file system...)
dim ws as workspace, db as database
dim rs as recordset
set ws=dbengine.workspaces(0)
set db=ws.opendatabase([path to database])
set rs=db.openrecordset([tablename], dbOpenSnapshot)
...
HTH,
--
Dan McGarry