[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Non-Updatable CRecordSets when a Query Issued?

Posted on 2000-01-28
12
Medium Priority
?
294 Views
Last Modified: 2013-11-20
If I issue an Open in MSVC++ 6 for a CRecordSet for an Access database without any parameters, the RecordSet is Updatable (I want to delete records), however; if I issue a query in the Open fucntion, the RecordSet is not Updatable. Why? How can I correct this?

This allows the RecordSet to be Updated:
m_NGIP01ASet->Open();

This does not:
m_NGIP01ASet->Open(AFX_DB_USE_DEFAULT_TYPE, _T(QueryStr), CRecordset::skipDeletedRecords);
0
Comment
Question by:maknight
  • 5
  • 2
  • 2
  • +3
12 Comments
 
LVL 3

Expert Comment

by:GlennDean
ID: 2397772
I believe instead of CRecordset::skipDeletedRecords use
CRecordset::none (this makes your recordset fully updatable, but is incompatible with skipDeletedRecords).
0
 

Author Comment

by:maknight
ID: 2397863
This doesn't work either. I've already tried it. The RecordSet is dynaset and the table only has 8 fields.
0
 

Author Comment

by:maknight
ID: 2398051
Below is my Query statement. I'm calling a stored Query within Access. The Query DOES work, but the Record Set is not Updatable.

CString QueryStr = "{call FindDataQuery1}";
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 9

Expert Comment

by:cdesigner
ID: 2398300
may be
m_NGIP01ASet->Requery();
can help
?
0
 
LVL 3

Expert Comment

by:GlennDean
ID: 2398401
Humm... maybe your open fails?

The following code works on my computer:

m_pSet->Open(CRecordset::dynaset,NULL,CRecordset::none);
BOOL updatable = FALSE;
updatable = m_pSet->CanUpdata();
  //updatable is now TRUE
0
 
LVL 5

Accepted Solution

by:
vachooho earned 400 total points
ID: 2410863
What is within your FindDataQuery1?

The problem may be with it query.
I will try to explain:

When you use more than 1 table in the query - it is possible that Access will not find way to update more than 1 table from recordset.

Look at this
SELECT * FROM Table1 INNER JOIN Table2 ON Table1.Field1 = Table2.Field2

Access 97 threat this as updatable recordset if you have member variables for ALL fields from both tables.

Thus I think the problem in your query.
Also try to use
SELECT * FROM FindDataQuery1

instead of {call FindDataQuery1}
Recordsets which use stored queries are not updatable.

0
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2460311
There is problem in your query. Can you post what is there in FindDataQuery1 ?
0
 

Author Comment

by:maknight
ID: 2475262
I'll post it later this evening. I'm not at a computer with the code on it. Thanks for all the comments thus far!!!
0
 

Author Comment

by:maknight
ID: 2476273
The Query as stored in Access (as best I can recall) is:

SELECT DataTable.* FROM DataTable (((WHERE DataTable.FromController = FALSE))) ORDER BY DataTable.KeyField, DataTable.Sequence

From within Access the Query works A-OK. If I put the actual Query statement in the Open function (instead of the "call" statement), it works OK except it does not perform the ORDER BY.
0
 
LVL 4

Expert Comment

by:inpras
ID: 2476833
try using first parameter instead of DEFAULT to CRecordset::dynaset
inpras
0
 
LVL 5

Expert Comment

by:vachooho
ID: 2477480
ORDER BY can be implemented in CRecordset m_strSort member variable
m_pSet->m_strSort = "DataTable.KeyField, DataTable.Sequence";
m_strFilter = "DataTable.FromController = FALSE";
m_pSet->Open(CRecordset::dynaset,"Select * from [DataTable]");


Hope this helps


0
 

Author Comment

by:maknight
ID: 2512517
The part about Recordsets from stored queries not being updatable answered the question, and vachooho's follow-up helped tie it up. Thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…
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.
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

613 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