Solved

Table structure updates with CdbObjects

Posted on 1998-05-13
3
166 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
GIF file bit manipulation for color change 5 104
Separate into files by filename 12 66
only14 challenge 19 63
Sed question 2 45
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now