Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set properties of new columns from C++ and ADOX

Status
Not open for further replies.

199999

MIS
Oct 17, 2002
1
CA
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();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top