Solved

Database?

Posted on 1998-09-10
1
128 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 37
Importing Special Characters in Dynamics GP Through Integration Manager 3 89
wordmultiple challenge 12 155
Sed question 2 122
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

761 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