Re: ADOX - Access table creation with nullable columns.



I've found that after the column is appended to the table, and table appended
to catalog, I can access the properties on the column object. I then tried
two approaches to (finally!) setting the Nullable property,
ColumnPtr->PutAttributes(adColNullable) and
PropertyPtr->PutValue(true)...both methods throw an exception :-

"Multiple-step OLE DB operation generated errors. Check each OLE DB status
value, if available. No work was done."

Any ideas what may be causing this exception?


New additional Code :-

//Get table and Columns objects
ADOX::TablesPtr tblsptr;
m_pCatalog->get_Tables(&tblsptr);
ADOX::_TablePtr tblptr = tblsptr->GetItem("MyTable");
ADOX::ColumnsPtr colsptr = tblptr->Columns;

//Get Column
ADOX::_ColumnPtr colptr = colsptr->GetItem("Column 1");

//Set Nullable
colptr->PutAttributes(ADOX::adColNullable); //Fails with MultiStep Error.

//Try accessing via Properties instead
ADOX::PropertiesPtr propsptr = colptr->GetProperties();
ADOX::PropertyPtr propptr = propsptr->GetItem("Nullable");

_variant_t setnullvar;
setnullvar.vt = VT_BOOL;
setnullvar = true;

propptr->PutValue(setnullvar); //Again fails with MultiStep Error.



"Ralph" wrote:


"Ralph" <nt_consulting64@xxxxxxxxx> wrote in message
news:%23w4GWShIIHA.4480@xxxxxxxxxxxxxxxxxxxxxxx

"Andy" <Andy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2E4C90C7-8C7B-482A-B4B0-622CFF47BC19@xxxxxxxxxxxxxxxx
Thanks for the advice. I've tried to access the properties associated
with
the Column object and hoped to enumerate through them to identify their
names
(Can't find any documentation on what these are!). I can get a pointer
to
the
properties interface only to find the property count equals zero. What
am
I
missing here?

VB code may help me - I hope the principles will be the same...

ADOX::_ColumnPtr m_pColumn;
TESTHR(m_pColumn.CreateInstance(__uuidof(ADOX::Column)));
m_pColumn->Name = name;
m_pColumn->Type = nType;
m_pColumn->DefinedSize = lSize;
m_pColumn->Attributes = ADOX::adColNullable;

m_Table->Columns->Append(m_pColumn->Name,nType,lSize);

//Get some properties
ADOX::PropertiesPtr pptr;
m_pColumn->get_Properties(&pptr);
long cnt = pptr->Count; //THIS RETURNS 0 !

Thanks,
Andy


This may or may not help. I often confuse myself when working with ADOX as
it appears to have the same model as ADO, but it is subtly different. So I
may be wrong, but I don't think "Column" has a property collection in
ADOX,
except for provider-specific properties. Your provider may not supply one.

To access existing declared properties (name, type, size, ...) I think you
have to read them one at a time. Just like you set them.


Should change "Your provider may not supply one." to "Your provider may not
supply any additional properties. ie, ADOX supplies the Collection, but it
may be empty."

-ralph



.



Relevant Pages

  • Re: ADOX - Access table creation with nullable columns.
    ... ADOX::PropertiesPtr pptr; ... I often confuse myself when working with ADOX as ... Should change "Your provider may not supply one." ...
    (microsoft.public.data.ado)
  • Re: ADOX - Access table creation with nullable columns.
    ... the Column object and hoped to enumerate through them to identify their ... VB code may help me - I hope the principles will be the same... ... may be wrong, but I don't think "Column" has a property collection in ADOX, ... except for provider-specific properties. ...
    (microsoft.public.data.ado)