Solved

Table structure updates with CdbObjects

Posted on 1998-05-13
3
171 Views
Last Modified: 2013-11-20
I am trying to build a database dynamically using the
CdbDatabase family of objects.  What I need to do is given
a list of tables and fields, I need to construct the
new tables.  The way I do it is I create the table with
the one field I know will be there, append it, and come
back to it later.  When I do, I am supposed to check to
see if the field exists in the table, and if not, add
the field to the table.  I can, it would seem, determine
if the field exists in the table, but can't add it to
the table, since all I can find for CdbTableDef is the
Create method, and not an Update or anything like it.
Any help would be appreciated.
0
Comment
Question by:Mestoph
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Expert Comment

by:tma050898
ID: 1310411
I've written a database editor for my current client that allows insurance analysts to graphically create databases. Therefore, I've done what you need to do. However, the current version uses the MFC DAO classes (as opposed to the dbDAO classes). I can send you that code now. If, however, you have already fixed a decision on dbDAO, let me know and I'll send you something tomorrow. The problem is that my original code used dbDAO, but I changed to the MFC DAO classes and now the code using dbDAO is in version control at work. Anyway, lemme know...
0
 

Author Comment

by:Mestoph
ID: 1310412
Yeah, if you could send it to me that would be great :)  I don't mind changing to MFC DAO
for this part of it.  I probably won't need to change it for the entire program anyway.  Thanks =)
0
 
LVL 3

Accepted Solution

by:
tma050898 earned 70 total points
ID: 1310413
Here's some simple code that creates a db, adds a new table and add a field to that table. I think the problem you said you were having was in adding fields. Anyway, if you need any more help just lemme know.

CDaoDatabase db;
db.Create(_T("c:\\test.mdb"), dbLangGeneral, dbVersion30);

CDaoTableDef table(&db);
table.Create(_T("TestTable"));
table.CreateField(_T("Test"), dbLong, 0);
table.Append();

db.Close();

HTH,
Tom
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 54
not able to insert into temp table 68 178
Smart Camera scanning and reading information 3 126
Way to decrease size of apk file 9 132
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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