Solved

Database?

Posted on 1998-09-10
1
131 Views
Last Modified: 2013-11-20
Hi,

I want to know if I have one database built from VB5.0 whether I can add or remove some fields to the database or not in Visual C++ 5.0.
If yes, how can I do this?

Thanks
0
Comment
Question by:ee_lcpaa
[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
1 Comment
 
LVL 7

Accepted Solution

by:
psdavis earned 30 total points
ID: 1322028
I use the DAO classes to manipulate the Microsoft Access format (.mdb).  Here's some source I used to add a field to the database


CDaoTableDef pUpdateDaoTable( m_pDaoDatabase );

pUpdateDaoTable.Open( _T( "Biograph" ) );
AddField( &pUpdateDaoTable, _T( "Middle Name"    ), dbText,     30, dbVariableField );
pUpdateDaoTable.Close( );

// And the function to run it
void CMyApp::AddField( CDaoTableDef *pTable, LPCTSTR strField, short sType, long lSize, long lAttribute )
{
   try
   {
   // If we can successfully get field information about this column, then it's already there.

      CDaoFieldInfo pFieldInfo;
      pTable->GetFieldInfo( strField, pFieldInfo );
      return;
   }
   catch( CDaoException* eDaoException )
   {
      eDaoException->Delete( );
   }

   try
   {
   // Now try to create the field

      pTable->CreateField( strField, sType, lSize, lAttribute );  
   }
   catch( CDaoException* eDaoException )
   {
      DaoReportError( eDaoException );
      eDaoException->Delete( );
   }
}

Phillip

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
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 this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Suggested Courses

617 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