ramahbou
July 19th, 1999, 03:54 PM
hi all,
I am creating a DB on fly( during run time using MFC).
For some reason that I could not figure out I can not create a Primary key on a table.
I am creating the index as following:
bool CDispositionTable::CreateAllFields(){
try{
this->CreateField ("DISPOSITION_CODE" ,dbInteger ,0 ,dbFixedField);
this->CreateField ("DESCRIPTION" ,dbText ,50 ,dbFixedField);
this->Append();
}
catch (CDaoException *e){
e->Delete ();
return false;
}
catch (CMemoryException *e)
{
e->Delete();
return false;
}
CDaoIndexFieldInfo *IndxFldInfo = new CDaoIndexFieldInfo[1];
CDaoIndexInfo IndxInfo;
//----- creating indexes for DISPOSITION_CODE ------//
IndxFldInfo->m_strName = _T("DISPOSITION_CODE");
IndxFldInfo->m_bDescending = FALSE;
IndxInfo.m_pFieldInfos = IndxFldInfo;
IndxInfo.m_strName = _T("DISPOSITION_CODE");
IndxInfo.m_nFields = 1;
IndxInfo.m_bPrimary = TRUE;
IndxInfo.m_bUnique = TRUE;
IndxInfo.m_bClustered = FALSE;
IndxInfo.m_bIgnoreNulls = TRUE;
IndxInfo.m_bRequired = FALSE;
try
{
this->CreateIndex(IndxInfo);
}
catch (CDaoException *e)
{
// create a message to display
CString message = _T("Couldn't create Index--Exception: ");
message += e->m_pErrorInfo->m_strDescription;
AfxMessageBox(message);
e->Delete();
return false;
}
catch (CMemoryException *e)
...
{
e->Delete();
return false;
}
What I am doing wrong ?
Thanks for your time.
I am creating a DB on fly( during run time using MFC).
For some reason that I could not figure out I can not create a Primary key on a table.
I am creating the index as following:
bool CDispositionTable::CreateAllFields(){
try{
this->CreateField ("DISPOSITION_CODE" ,dbInteger ,0 ,dbFixedField);
this->CreateField ("DESCRIPTION" ,dbText ,50 ,dbFixedField);
this->Append();
}
catch (CDaoException *e){
e->Delete ();
return false;
}
catch (CMemoryException *e)
{
e->Delete();
return false;
}
CDaoIndexFieldInfo *IndxFldInfo = new CDaoIndexFieldInfo[1];
CDaoIndexInfo IndxInfo;
//----- creating indexes for DISPOSITION_CODE ------//
IndxFldInfo->m_strName = _T("DISPOSITION_CODE");
IndxFldInfo->m_bDescending = FALSE;
IndxInfo.m_pFieldInfos = IndxFldInfo;
IndxInfo.m_strName = _T("DISPOSITION_CODE");
IndxInfo.m_nFields = 1;
IndxInfo.m_bPrimary = TRUE;
IndxInfo.m_bUnique = TRUE;
IndxInfo.m_bClustered = FALSE;
IndxInfo.m_bIgnoreNulls = TRUE;
IndxInfo.m_bRequired = FALSE;
try
{
this->CreateIndex(IndxInfo);
}
catch (CDaoException *e)
{
// create a message to display
CString message = _T("Couldn't create Index--Exception: ");
message += e->m_pErrorInfo->m_strDescription;
AfxMessageBox(message);
e->Delete();
return false;
}
catch (CMemoryException *e)
...
{
e->Delete();
return false;
}
What I am doing wrong ?
Thanks for your time.