Solved

Table structure updates with CdbObjects

Posted on 1998-05-13
3
168 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
  • 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 100
Importing Special Characters in Dynamics GP Through Integration Manager 3 76
wait notify demo infinite loop 3 114
Fibonacci challenge 11 124
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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

832 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