Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Database Lockout

Posted on 1998-10-04
5
Medium Priority
?
264 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
ID: 1322906
Pleace tell me hay you use CDaoRecordset::Open.

0
 
LVL 1

Expert Comment

by:VAM345
ID: 1322907
Pleace tell me hay you use CDaoRecordset::Open.

0
 

Author Comment

by:BlackRussian
ID: 1322908
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
ID: 1322909
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 600 total points
ID: 1322910
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

926 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