Click to See Complete Forum and Search --> : Unmanaged VC++ 6 code to VC++ 8 (2005)


arvindbhateja
July 14th, 2006, 05:52 AM
Can anyone tell me - What is the alternate to CMapStringToOb MFC class in C++/CLI.
And Plz can u suggest me what should I do to write the following code in C++/CLI :


int nCount = clRecSet.GetFieldCount();
// Th efield count.
CDaoFieldInfo* pclFieldInfo; // Pointer for field info.
CMapStringToOb clTables; // For table.
CPtrList* pclFields = NULL; // Pointer list.

for (int ii = 0; ii < nCount; ii++)
{
pclFieldInfo = new CDaoFieldInfo;
clRecSet.GetFieldInfo(ii, *pclFieldInfo, AFX_DAO_SECONDARY_INFO);
if (clTables.Lookup (pclFieldInfo->m_strSourceTable,
(CObject*&) pclFields) != TRUE )
{
pclFields = new CPtrList;
clTables.SetAt (pclFieldInfo->m_strSourceTable, pclFields);
}
pclFields->AddTail ((void *) pclFieldInfo);
}
// Now the fields are grouped together by table name
...
...

POSITION pos = clTables.GetStartPosition();
// Position index.
while (pos != NULL)
{
pclFields = NULL;
CPtrList* pclFields;
CDaoFieldInfo* pFieldInfo; // The field info.

clTables.GetNextAssoc (pos, strCurrTbl, (CObject*&) pclFields);
POSITION posField = pclFields->GetHeadPosition();
int nIndex = 0; // Index for the loop.
while (posField != NULL)
{
pFieldInfo = (CDaoFieldInfo *) pclFields->GetNext (posField);

.....



In the the above code I can replace :

CMapStringToOb -> ?
CPtrList -> ArrayList
CDaoFieldInfo -> DataColumn (Problem with fetching the database table name not the table name which comes from dataset object)

In DataColumn I can't get the name of the table, the column actually belongs to as we can do in CDaoFieldInfo::m_strSourceTable.

Actually I've to map the name of the table with it's corresponding column and put that into a CMapStringToOb object

Thanks...

cilu
July 18th, 2006, 04:38 AM
You can use a std::map to replace CMapStringToOb.