OOFILE | Downloads | Purchasing | Press | Services | Company Information | Soapbox | References | F.A.Q. | HOME

OOFTST 15 - open two databases sequentially

This sample demonstrates opening two databases sequentially.


#include "oofile.h"	// the general oofile library
#include "ooftst02.h"	// the declarations for the database classes we will be using in this test.
  

These global variables define the database using the ooftst02 classes 

	TEST_CONNECT    theDB;
	dbPatients     Patients;
	dbVisits	Visits;
	dbRelationship PatientVisits(Patients.Visits, Visits.Patient);
	
  
int main()
{
	cout << "OOFILE Validation Suite - Test 15\n"
		 << "Simple test to demonstrate opening two databases" << endl
		 << "at different times" << endl;  

This code determines what platform we are running under and assigns a name for the first database file accordingly.

	#ifdef TESTING_DBASE
		#ifdef _Macintosh
			const char* kExistsName =  ":ooftst15:Patients.dbf";
			const char* kDatabaseName = ":ooftst15:";
		#else
			const char* kExistsName =   "People.dbf"
			const char* kDatabaseName = "";
		#endif	  
	#else
		const char* kDatabaseName = "ooftst15.db";
		const char* kExistsName = kDatabaseName;
	#endif  

Now we open the old file or create a new one, adding new test data.

	if (dbConnect::fileExists(kExistsName)) {
		theDB.openConnection(kDatabaseName);
	}
	else {
		theDB.newConnection(kDatabaseName);
		Patients.AddTestData();
	}
	  

We print the first database.

	cout << "Dumping the first database, Patients & Visits" << endl << endl 
		 << theDB
		 << endl << endl;
	  

We close the first database so we can open the other one.

	theDB.close();
	  


We now create the second database

	TEST_CONNECT    theDB2;
	dbPeople     People;  

This code determines what platform we are running under and assigns a name for the second database file accordingly.

	#ifdef TESTING_DBASE
		#ifdef _Macintosh
			kExistsName =  ":ooftsx15:Patients.dbf";
			kDatabaseName = ":ooftsx15:";
		#else
			kExistsName =   "Patients.dbf"
			kDatabaseName = "";
		#endif	  
	#else
		kDatabaseName = "ooftsx15.db";
		kExistsName = kDatabaseName;
	#endif
	  

Now we open the old file or create a new one, adding new test data.

	if (dbConnect::fileExists(kExistsName)) {
		theDB2.openConnection(kDatabaseName);
	}
	else {
		theDB2.newConnection(kDatabaseName);
		People.AddTestData();
	}
		  

We print the second database.

	cout << "Dumping the second database, People" << endl << endl << theDB2;
	  
	cout << "Done" << endl;
	  
	return EXIT_SUCCESS;
}        

 

Feature index

(c) Copyright A.D. Software 1994-2000 (All Rights Reserved).
Last Updated: 9th September 2001