Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Database?

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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: 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.
Loops Section Overview

916 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