Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Database?

Posted on 1998-09-10
1
Medium Priority
?
133 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 90 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

715 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