Solved

Database?

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

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

20 Experts available now in Live!

Get 1:1 Help Now