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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenDatabase problem 3

Status
Not open for further replies.

ronh42

Programmer
Nov 20, 2002
10
US
A quick question. I'm attempting to load a VB form with data from an Access DB. This works fina as long as my database is on my c: drive. If I try and open it from d: drive(CD) I get 3051 Run time error. Which basically says VB thinks the database is already in use exculsively by another user. Is there a way around this?

Thanks for any help.

PS It's on a CD for demo purposes only.
 
Could it be that it expects to have read/write access to DB but CD will only allow read?
 
Are you getting this error even if you just read from the db? I had such a problem when I copied the database to a different machine and it was copied as "read-only" so I couldn't upend data...
 
Yes only when I read it. All I want to do is read it. There will be no updating or appending.
 
Was the database exclusively locked when you copied it to the cd, ie are there any lock files copied accross to the cd (*.ldb)?
 
What code are you using to open it? Could it be that you are specifying something other than just read access even though that's all you need?
 
Here's the code.

Set Db = OpenDatabase("d:\GSE_GEO_INFO.mdb")

Set RsSt = Db.OpenRecordset("tblStateCodes", dbOpenSnapshot)
Set RsMsa = Db.OpenRecordset("tblMsaSelect", dbOpenSnapshot)

Do Until RsSt.EOF = True
cboSelState.AddItem (RsSt.Fields("StName").Value)
RsSt.MoveNext
Loop
cboSelState.ListIndex = 0

Do Until RsMsa.EOF = True
cboSelMSA.AddItem (RsMsa.Fields("MsaName").Value)
RsMsa.MoveNext
Loop
cboSelMSA.ListIndex = 0
 
Extract from MSDN help, documents

Set database = workspace.OpenDatabase (dbname, options, read-only, connect)

read-only Optional. A Variant (Boolean subtype) value that is True if you want to open the database with read-only access, or False (default) if you want to open the database with read/write access.

I'm not sure if this is the same OpenDatabase as you are using but suggestion is that default is read/write.
 
I think you will find that the database engine needs write access even if you don't. I've encountered this problem before, and we had to copy from the CD to a harddrive and take off the read-only flag (as nicsin said).

I don't know if anyone knows of a workaround? Different database drivers?

Regards

Daren


Must think of a witty signature
 
Worth trying

Set Db = OpenDatabase("d:\GSE_GEO_INFO.mdb",,True)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top