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

accessing a database

Status
Not open for further replies.

Alira

Programmer
Mar 21, 2001
77
CA
Hello everyone!

I'm getting an error "Unable to access database & path & name.It may be opened by another user in exclusive mode or you don't have permittion to use it"

Now some details.
Database *.mdb (Access 97)
VB 6.0 Sp5 front end.
Deveoped under Win 2000 pro (and here it is working)
Built using PDW on Win 98 station.
Installed also on on Win 98...
Usind ADO, User DSN...
what else should I say?
I can give a 100% that nobody was using this database at the time of testing and it is not password protected...
MDAC 2.6 and DCOM98 is installed...

Please, help me..
 
has you permisson to create an .ldb file into the database's folder?
How the message appears? When you open your database? ..or after you open a form (with a recordset from the named database) and try to run a VBA CODE?
 
Sounds to me like you have the path to the DB in a string, like this:

connection.open "C: & Path & Name"

To correct a mistake like this all you would have to do is this:
connection.open "C:" & Path & Name

This may not at all be whats wrong, but it would be consistent with the error message you recivied.

If this doesn't help you, post some code showing how you connect to the DB and populates the RS, and I'll have a look on it.

Good Luck!
-Mats Hulten
 
Hi! Thanks for answering!!

To ide

I do have a permission to create a .ldb file in this folder.
The error pops-up when I'm trying to connect to a database.

To MatsHulten

I was thinking about possible cause and tried differet ways of accessing the database. And every time I get the same error...
Here are two examples of how I was trying to do it:
1)
Dim db As Connection

Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;"&_
"DataSource=\\mypath\myfile.mdb;"

Set rst = New Recordset
rst.Open "MySqlStatement"

2)
'You can see that here I was using data environment
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim SQL As String

Set cnn = New ADODB.Connection
my.cnn.Open
Set rst = New ADODB.Recordset
rst.LockType = adLockOptimistic
rst.CursorType = adOpenKeyset
Set rst.ActiveConnection = my.cnn
SQL = "SELECT * FROM ..."

rst.Source = SQL
rst.Open
 
I've got another error today:
# 2147467259 Operation must use updateable query.

Why is that??
 
Error 2147467259 (0x80004005) is the generic E_FAIL, it means that the underlying component did not have a specific error number for the condition encountered.

As to the errors you are recieving, the code you posted looks fine to me, however I don't use the data enviroment very much, so it may be that code contains errors.

In the first example you posted you are using a DB on a network share. I suggest that you for debugging purposes copy that DB to your local system, then run your code without having Access running. This just to make sure that there isn't any Access data sharing violations. (Access isn't the most multi user friendly DB in exsistence... ;)

If you still recives errors I suggest you put a breakpoint at the declaration of the connection object and a watch on the connection and recordset object. Then step though the code and watch the two objects carefully. Hopfully this will give you some clue as to what's wrong.

As to the error message "Operation must use updateable query" I found something in MS KB that relates:
Code:
SYMPTOMS
The following is a common error encountered when using ActiveX Data Objects (ADO) with Active Server Pages:



Microsoft OLE DB Provider for ODBC Drivers error '80004005' 
[Microsoft][ODBC Microsoft Access 97 Driver] Operation must use an updateable query. 



CAUSE
This article explains the three primary causes of this error, and the workarounds. Although this article refers to Microsoft Access databases, the information provided here also applies to other types of databases. 



RESOLUTION
This error is typically encountered when your script attempts to perform an UPDATE or some other action that alters the information in the database. This error occurs because ADO is unable to write to the database for one of the following reasons:



The most common reason is that the Internet Guest account (IUSR_MACHINE) does not have Write permissions on the database file (.mdb). To fix this problem, use the Security tab in Explorer to adjust the properties for this file so that the Internet Guest account has the correct permissions. NOTE: When using Microsoft Access databases with ADO, it is also necessary to give the Internet Guest account Write permissions on the directory containing the .mdb file. This is because Jet creates an .ldb file to handle database locking. You may also need to give read/write permission on the "Temp" folder because Jet may create temporary files in this directory.


A second cause of this error is that the database was not opened with the correct MODE for writing. If you perform the Open on the Connection object, you use the Mode property to indicate the permissions on the connection as shown here:




      SQL = "UPDATE Products Set UnitPrice = 2;"
      Set Conn = Server.CreateObject("ADODB.Connection")
      Conn.Mode = 3      '3 = adModeReadWrite
      Conn.Open "myDSN"
      Conn.Execute(SQL)
      Conn.Close
 
NOTE: By default, the MODE is set to 0(adModeUnknown), which generally allows updates.


Another cause of this error is that the "Read Only" setting may be checked in the Options page for this DSN in the ODBC Manager.


The last issue and work around pertains to any SQL data source. The error can be caused by SQL statements that violate referential integrity of the database. Here are a few of the most common queries that fail:



The simplest group to deal with are those you cannot change: crosstab, SQL pass-through, union, or update (or make-table) action queries that have UniqueValue properties set to Yes. 


Another very common cause is when the join includes linked ODBC tables that do not have unique indexes. In this case, there is no way for SQL to guarantee that records are unique in a table that has fields whose value will change with the query. 


One cause does have a robust workaround. If you try to update a join field on the "one" side of a "one-to-many" query it will fail unless you turn on cascading updates. This way, you delegate referential integrity to the JET engine. 



STATUS
This behavior is by design.

Good Luck!
-Mats Hulten
 
Thank you for response!
However, this error comes when I'm no trying to wright...
I read the data...
I couldn't debug also, because on my PC everything works fine.
Only when I install this program on another workstation errors occure.
I will install VB today and try to debug it over there...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top