Solved

Table structure updates with CdbObjects

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

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. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

627 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