Re: ADOX - Access table creation with nullable columns.




"Andy" <Andy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8C2D8BD5-1A57-4B0A-9294-8A9A868D0A56@xxxxxxxxxxxxxxxx
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.

<snipped>

Again I'm confused by the use of a Property Collection. ADOX doesn't have a
collection for the nullable property. Only for Provider Supplied properties.
PutProperties????

I haven't used C with ADOX for quite a while. In VB it would be something
like this... [Air Code!]

Dim tbl As ADOX.Table: Set tbl = New ADOX.Table
Dim col As ADOX.Column: Set col = New ADOX.Column
' create the cat, the table, and add the number of columns,
and all that
....
' then for each column
col.Name = "FirstField"
col.Type = DataTypeEnum.adVarWChar
col.DefinedSize = 255
col.Attributes = ColumnAttributesEnum.adColNullable
.....
tbl.Columns.Append(col.Name)

http://msdn2.microsoft.com/en-us/library/ms803892.aspx
http://www.codeguru.com/cpp/data/mfc_database/ado/article.php/c4343/#_Toc1461087

hth
-ralph





.