Need to add a column to my database file from VC++ 
Author Message
 Need to add a column to my database file from VC++

I support a large Visual C++ application that uses CDaoRecordset objects to
read from, and write to, my Microsoft Access .MDB files.

My question is "How do I add a new column to an existing MDB file?"

For example, let's say I have Address.mdb with the following columns:

Name   Street   City   State

Now I want to add Zip as the last column from inside my VC++ application. Is
their a method for doing this?

Michael T.



Mon, 17 Nov 2003 23:13:30 GMT  
 Need to add a column to my database file from VC++
Yes, of course

CDaoRecordset set;
.....

CDaoTableDef daoTable(set.m_pDatabase);
daoTable.Open(_T("Your Table Name"));
daoTable.CreateField(_T("Zip"), dbText,15,dbVariableField|dbUpdatableField);


???Y??:

Quote:
> I support a large Visual C++ application that uses CDaoRecordset objects
to
> read from, and write to, my Microsoft Access .MDB files.

> My question is "How do I add a new column to an existing MDB file?"

> For example, let's say I have Address.mdb with the following columns:

> Name   Street   City   State

> Now I want to add Zip as the last column from inside my VC++ application.
Is
> their a method for doing this?

> Michael T.



Tue, 18 Nov 2003 00:39:57 GMT  
 Need to add a column to my database file from VC++
Thank you so much, as your suggestion worked perfectly.

I can even use daoTable.GetFieldCount() to see if my new field needs to be
added. In other words, when a customer first runs my executable I will need
to add the field, but now my program is smart enough to determine that the
field has already been added.

After 5+ years of MFC programming without using database classes, it is
certainly refreshing to work with something as easy (comparatively speaking)
as the CDaoRecordset and Microsoft Access files. I'm having a blast.

Michael


| Yes, of course
|
| CDaoRecordset set;
| .....
|
| CDaoTableDef daoTable(set.m_pDatabase);
| daoTable.Open(_T("Your Table Name"));
| daoTable.CreateField(_T("Zip"),
dbText,15,dbVariableField|dbUpdatableField);
|

| ???Y??:

| > I support a large Visual C++ application that uses CDaoRecordset objects
| to
| > read from, and write to, my Microsoft Access .MDB files.
| >
| > My question is "How do I add a new column to an existing MDB file?"
| >
| > For example, let's say I have Address.mdb with the following columns:
| >
| > Name   Street   City   State
| >
| > Now I want to add Zip as the last column from inside my VC++
application.
| Is
| > their a method for doing this?
| >
| > Michael T.



Tue, 18 Nov 2003 07:04:04 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Need to add a column to my database file from VC++

2. adding columns to excel with dao & vc++

3. adding columns to excel with dao & vc++

4. ListCtrl on File->New Columns adding (duplicating)

5. Can I add a column to my database file from VC++?

6. Adding columns to ListView after it's been added to a form

7. Need help adding to table via ADO.NET (MS Access database)

8. Need VC++6 Example to Update, Delete, Add and Search on Access Data

9. VB programer needing help learning how to add custome control to VC++ application

10. 3 Need Database, RTOS and File System developers

11. HELP: Binary Large Objects (need to store binary file w/in database)

12. HELP: Binary Large Objects (need to store binary file w/in database)

 

 
Powered by phpBB® Forum Software