Solved

Database Lockout

Posted on 1998-10-04
5
220 Views
Last Modified: 2013-11-20
I am developing a database app using DAO classes. One of my views contains a spliiter window ala Windows explorer that displays information from a table in the righ hand pane. The information was retrieved using a SQL statement SELECT * from table. The other pane displays information from multiple tables using an SQL inner join statement. There is 1 table that is common for both views. These recordset objects are created in sepperate clases created using the RUNTIME (class,etc.. etc) statement in the OnCreatClient meber function of the child window conatianing this spitter view.  Now at last the problem. When I try to close the child window containing this view I get the error CANNOT LOCK TABLE "tablename". This is the table that is common to both classes. I have code in both classes descrutors to close the recordset set objects. Note I have only 1 databse object create in the App class. Both recordset objects are connected to this database object. Help?.
0
Comment
Question by:BlackRussian
  • 3
5 Comments
 
LVL 1

Expert Comment

by:VAM345
Comment Utility
Pleace tell me hay you use CDaoRecordset::Open.

0
 
LVL 1

Expert Comment

by:VAM345
Comment Utility
Pleace tell me hay you use CDaoRecordset::Open.

0
 

Author Comment

by:BlackRussian
Comment Utility
Yes I use the CDaoRecordset::Open statment. In the OnCreate function of each class I use recordset = new CDaoRecordset (theApp.database); to connect the recordset object to the single global database object, I then use  recordset->Open(dbOpenSnapshot,SQLstmt); to create the recordset object.  
0
 
LVL 1

Expert Comment

by:VAM345
Comment Utility
I my work I use recordet form one commont table in meny recordset and this work wor me.
Pleace tell me more of you SQL stmt? You problem mey be in other you code.
0
 
LVL 1

Accepted Solution

by:
Fargo earned 200 total points
Comment Utility
Take a close look of the nOptions parameter of the CDaoRecorset::Open(...) function. There you can set the way the recordset co-works with the other recordsets, that have open the table. When you do changes to a record of a recordet, whenever an Update is called (which may happen when you close the recordset), DAO locks the table for writing, and if it's already locked by another recordset, this exception is thrown. You have to open one of your recordsets for read-only. This is done when you set the nOption parameter to dbReadOnly.
I'm not informed with the specification of your project, so I can't tell more, but if you read carefully what MSDN says about CDaoRecordet::Open(...), you may come to a conclusion.

Hope I was help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now