Hi, All
I am trying to add new columns to the table of my Access 2000 database form my ActiveX project. I used ADO, ADOX and OLE DB. I want the new column has the following properties:
1. Required = no, i.e., data entry is not required each time when a new record will be added to the table
2. Allow Zero length = yes.
I have the following code that will set the Allow Zero Length to be true, but I do not know
how to set the Required to be false/no. The codes commented out do not work, I really do not understand why.
I have spent days for those few lines of code. Any help will be highly appreciated.
m_pTable->Name=TableName;
m_pColumn->Name = _bstr_t(ColumnName);
m_pColumn->Type = ADOX::adVarWChar;
m_pColumn->DefinedSize = 220;
m_pColumn->Attributes = ADOX::adColNullable;
m_pCatalog->Tables->GetItem(TableName)->Columns->Append(m_pColumn->Name,ADOX::adVarWChar,220);
m_pCatalog->Tables->GetItem(TableName)->Columns->GetItem(ColumnName)->Properties->GetItem("Description"->Value = "added new field";
//m_pCatalog->Tables->GetItem(TableName)->Columns->GetItem(ColumnName)->Properties->GetItem("Nullable"->Value = true;
//m_pCatalog->Tables->GetItem(TableName)->Columns->GetItem(ColumnName)->GetProperties()->GetItem("Nullable"->PutValue(true);
//m_pCatalog->Tables->GetItem(TableName)->Columns->GetItem(ColumnName)->Properties->GetItem("Jet OLEDB:IISAM Not Last Column"->Value = false;
m_pCatalog->Tables->GetItem(TableName)->Columns->GetItem(ColumnName)->Properties->GetItem("Jet OLEDB:Allow Zero Length"->Value = true;
m_pCatalog->Tables->GetItem(TableName)->Properties->Refresh();
I am trying to add new columns to the table of my Access 2000 database form my ActiveX project. I used ADO, ADOX and OLE DB. I want the new column has the following properties:
1. Required = no, i.e., data entry is not required each time when a new record will be added to the table
2. Allow Zero length = yes.
I have the following code that will set the Allow Zero Length to be true, but I do not know
how to set the Required to be false/no. The codes commented out do not work, I really do not understand why.
I have spent days for those few lines of code. Any help will be highly appreciated.
m_pTable->Name=TableName;
m_pColumn->Name = _bstr_t(ColumnName);
m_pColumn->Type = ADOX::adVarWChar;
m_pColumn->DefinedSize = 220;
m_pColumn->Attributes = ADOX::adColNullable;
m_pCatalog->Tables->GetItem(TableName)->Columns->Append(m_pColumn->Name,ADOX::adVarWChar,220);
m_pCatalog->Tables->GetItem(TableName)->Columns->GetItem(ColumnName)->Properties->GetItem("Description"->Value = "added new field";
//m_pCatalog->Tables->GetItem(TableName)->Columns->GetItem(ColumnName)->Properties->GetItem("Nullable"->Value = true;
//m_pCatalog->Tables->GetItem(TableName)->Columns->GetItem(ColumnName)->GetProperties()->GetItem("Nullable"->PutValue(true);
//m_pCatalog->Tables->GetItem(TableName)->Columns->GetItem(ColumnName)->Properties->GetItem("Jet OLEDB:IISAM Not Last Column"->Value = false;
m_pCatalog->Tables->GetItem(TableName)->Columns->GetItem(ColumnName)->Properties->GetItem("Jet OLEDB:Allow Zero Length"->Value = true;
m_pCatalog->Tables->GetItem(TableName)->Properties->Refresh();