//添加一份新的总表
void CEle_Power_DecomposeView::ReadFromMDB( CString filename )
{
	CMainFrame* pMain=(CMainFrame*)AfxGetApp()->m_pMainWnd;
	pMain->panel_test = "读取数据中";
	pMain->OnPaint();

	CDaoDatabase db;
	CDaoRecordset RecSet(&db);

	db.Open(filename);
	RecSet.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM t_power_data",NULL);
	

	Zongbiao.AddNewZongbiao(RecSet);
	
	RecSet.Close();
	db.Close();

	pMain->panel_test = "读取数据完毕";
	pMain->OnPaint();

	ReadMDBFlag = 1;
	ReadMDBFinish = 1;
	
	((CTab1*)m_DlgArray[0])->UpdateList(Zongbiao);
}
Beispiel #2
0
 static CDaoDatabase* createDB( const CString& dbName, bool openExist = false )
 {
     CDaoDatabase* pDB = new CDaoDatabase();
     CFileFind ff;
     if( ff.FindFile( dbName ) )
     {
         if( openExist )
         {
             pDB->Open( dbName );
         }
         else
         {
             CFile::Remove( dbName );
             pDB->Create( dbName );
         }
     }
     else
     {
         pDB->Create( dbName );
     }
     return pDB;
 }
BOOL COpenAccessdatabase::ValidDB(CString csPath, BOOL bUpgrade)
{
	BOOL bResult = TRUE;
	BOOL bUpgraded = FALSE;
	try
	{
		CDaoDatabase db;

		try
		{
			db.Open(csPath);
		}
		catch(CDaoException* e)
		{
			TCHAR   szErrorMessage[512];
			UINT    nHelpContext;

			if(e->GetErrorMessage(szErrorMessage, 512, &nHelpContext))
			{
				if(STRCMP(szErrorMessage, _T("Unable to initialize DAO/Jet db engine.")) == 0)
				{
					e->Delete();
					return ERROR_OPENING_DATABASE;				
				}
			}
			e->ReportError();
			e->Delete();

			return FALSE;
		}


		CDaoTableDef table(&db);
		CDaoFieldInfo info;

		table.Open(_T("Main"));
		table.GetFieldInfo(_T("lID"), info);
		table.GetFieldInfo(_T("lDate"), info);
		ON_FIELD_ABSENT(_T("mText"), Upgrade_mText(db)); // +mText, -strText, -strType
		table.GetFieldInfo(_T("lShortCut"), info);
		table.GetFieldInfo(_T("lDontAutoDelete"), info);
		table.GetFieldInfo(_T("lTotalCopySize"), info);
		ON_FIELD_ABSENT(_T("bIsGroup"), Upgrade_Groups(db));
		table.GetFieldInfo(_T("lParentID"), info); // part of Upgrade_Groups
		table.GetFieldInfo(_T("dOrder"), info);  // part of Upgrade_Groups
		ON_FIELD_ABSENT(_T("lDataID"), Upgrade_ShareData(db)); // +lDataID, -lParentID
		table.Close();

		table.Open(_T("Data"));
		table.GetFieldInfo(_T("lID"), info);
		table.GetFieldInfo(_T("lDataID"), info); // part of Upgrade_ShareData()
		table.GetFieldInfo(_T("strClipBoardFormat"), info);
		table.GetFieldInfo(_T("ooData"), info);
		table.Close();

		table.Open(_T("Types"));
		table.GetFieldInfo(_T("ID"), info);
		table.GetFieldInfo(_T("TypeText"), info);
		table.Close();
	}
	catch(CDaoException* e)
	{
		ASSERT(FALSE);
		e->Delete();
		return FALSE;
	}

	// if we upgraded, perform full validation again without upgrading
	if( bUpgraded )
		return ValidDB(csPath, FALSE);

	return bResult;
}