//***************************************************************************
BOOL CBCGPDAOGridCtrl::GetFieldList (LPCTSTR lpszTable, CStringList& lstField)
{
	ASSERT (lpszTable != NULL);

	lstField.RemoveAll ();

	try
	{
		if (m_pDataBase == NULL)
		{
			ASSERT (FALSE);
			return FALSE;
		}

		ASSERT_VALID (m_pDataBase);

		if (!m_pDataBase->IsOpen ())
		{
			ASSERT (FALSE);
			return FALSE;
		}

		CDaoRecordset* pRecordSet = new CDaoRecordset (m_pDataBase);

		CString strSQL = _T("SELECT * FROM ");
		strSQL += lpszTable;

		pRecordSet->Open (AFX_DAO_USE_DEFAULT_TYPE, strSQL);

		if (!pRecordSet->IsOpen ())
		{
			delete pRecordSet;
			return FALSE;
		}

		const short nColumns = pRecordSet->GetFieldCount ();

		for (short nColumn = 0; nColumn < nColumns; nColumn++)
		{
			CDaoFieldInfo info;
			pRecordSet->GetFieldInfo (nColumn, info);

			lstField.AddTail (info.m_strName);
		}

		pRecordSet->Close ();
		delete pRecordSet;
	}
	catch (CDaoException* pEx)
	{
		OnDaoException (pEx);
		pEx->Delete ();

		return FALSE;
	}

	return TRUE;
}
示例#2
0
void CDaoRecordView::OnInitialUpdate()
{
	ASSERT_VALID(this);

	CDaoRecordset* pRecordset = OnGetRecordset();
	// recordset must be allocated already
	ASSERT(pRecordset != NULL);

	if (!pRecordset->IsOpen())
	{
		CWaitCursor wait;
		pRecordset->Open();
	}

	if (!pRecordset->IsEOF())
	{
		// Determine recordset properties for move button enabling
		if (pRecordset->CanBookmark())
		{
			// Get the bookmark of the first record
			m_varBookmarkCurrent = pRecordset->GetBookmark();
			m_varBookmarkFirst = m_varBookmarkCurrent;
		}

		// Enable forward scrolling buttons
		m_nStatus |= AFX_DAOVIEW_SCROLL_NEXT;

		// Enable backward scrolling buttons if possible
		if (pRecordset->CanScroll())
		{
			m_nStatus |= AFX_DAOVIEW_SCROLL_LAST;
			m_nStatus |= AFX_DAOVIEW_SCROLL_BACKWARD;
		}
		else
		{
			m_nStatus &= ~AFX_DAOVIEW_SCROLL_LAST;
			m_nStatus &= ~AFX_DAOVIEW_SCROLL_BACKWARD;
		}
	}
	else
	{
		// Disable scrolling
		m_nStatus &= ~AFX_DAOVIEW_SCROLL_NEXT;
		m_nStatus &= ~AFX_DAOVIEW_SCROLL_LAST;
		m_nStatus &= ~AFX_DAOVIEW_SCROLL_BACKWARD;
	}

	CFormView::OnInitialUpdate();
}
示例#3
0
// globale Funktion 
// richtiger Tabellentyp
BOOL CheckTable (CDaoRecordset &Set, FieldKonvert *pInfo, const CString& strTableName)
{
	try
	{
		CWaitCursor wc;
		CMutex mt;
		ASSERT (Set.IsOpen ());
		ASSERT (NULL != pInfo);

	//	Suche alle Felder
		CDaoFieldInfo FieldInfo;
		CString strError;
		while (pInfo && pInfo -> pFieldName && *pInfo -> pFieldName)
		{
			try
			{
				Set.GetFieldInfo (pInfo -> pFieldName, FieldInfo);			
			}
			catch (CMemoryException *me)
			{
				me -> ReportError ();
				me -> Delete ();
				return FALSE;
			}
			catch (CDaoException *de)
			{
				de -> Delete ();
				AfxFormatString1 (strError, IDS_FIELD_NOT_FOUND, pInfo -> pFieldName);
				throw strError;
			}
			
		//	Datentyp ok ?
			if (FieldInfo.m_nType != pInfo -> sType)
			{
				AfxFormatString1 (strError, IDS_FIELD_NO_TYPE, pInfo -> pFieldName);
				throw strError;
			}
		
		//	ggf. auch Länge vergleichen
			if ((pInfo -> sLen > 0) &&
				(pInfo -> sLen < FieldInfo.m_lSize))	// angeg. Länge muß kleiner gleich tatsächlicher sein
			{
				CString strLen;
				strLen.Format ("%ld", pInfo -> sLen);
				AfxFormatString2 (strError, IDS_FIELD_NO_LEN, pInfo -> pFieldName, strLen);
				throw strError;
			}				

			pInfo++;
		}			

		return TRUE;
	}
	catch (CString str)
	{
	//	Struktur stimmt nicht: Meldung an Nutzer
		CString strOutput;
		AfxFormatString2 (strOutput, IDS_NO_VALID_STRUCTUR, strTableName, str);
		((CGakApp *) AfxGetApp ()) -> OutputMessage (strOutput);
	}

	return FALSE;
}