Solved

Create field from openCDaoRecorset table

Posted on 1999-01-18
5
236 Views
Last Modified: 2010-05-18
How do I create a field in an existing table from a CDaoRecordset that is already open via CDaoRecordset::Open( ) ?  My my class name is m_csetExams deriverd from CDaoRecordset
0
Comment
Question by:Surfer
5 Comments
 
LVL 1

Expert Comment

by:Seeker092397
ID: 1184483
You cann't create new field in the table using CDaoRecordset. You have to open the table using CDaoTableDef and call its CreateField function.
0
 

Author Comment

by:Surfer
ID: 1184484
How do I create a field in an already created table using CDaoTableDef?  I have only seen exaples on using CDaoTableDef to create the table and then adding tables.  I get an error msg telling me the table is already open if a trie to open it.  This makes sence because the recordset is open to grat the table info.  Do I close the recordset and reopen it using CDaoTableDef?  This  seems like I am doing to much work.
0
 

Author Comment

by:Surfer
ID: 1184485
Adjusted points to 200
0
 
LVL 1

Expert Comment

by:The_Brain
ID: 1184486
You cant open on an open database, if you wan't to restart it just call
depending on (.) no pointer, (->) pointer to member
mcSetExams(./->)Requery()

(I think that might do it.)

I will try to do it.  Could you tell me exactly what you are starting with and what you want to do. and what you will end with?

then I can try to help.

0
 
LVL 4

Accepted Solution

by:
pellep earned 200 total points
ID: 1184487
First you must call Close() in your CDaoRecordset. Then open a CDaoTableDef, call CreateField() and then call Append() to add the field to the fields collection. Now, close the tabledef and reopen your CDaoRecordset using the Open() command (with appropriate variables).
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

792 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