المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Removing AutoIncrement from Access database column



C# Programming
05-20-2009, 05:11 PM
Hey!

I'm trying to remove the AutoIncrement from an MS Access database. I'm using ADOX. The table has two foreign relations, these relations are removed (which works fine), however when I try to remove the Autoincrement property from the column, i receive the following exception :

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

m_catDatabase.let_ActiveConnection(m_strConnectionString);
foreach (Key keyRelation in m_catDatabase.Tables["Kengetallen"].Keys)
{
if ((keyRelation.Type == KeyTypeEnum.adKeyForeign) && (keyRelation.RelatedTable == "ProductGroep"))
{
m_catDatabase.Tables["Kengetallen"].Keys.Delete(keyRelation.Name);
break;
}
}
foreach (Key keyRelation in m_catDatabase.Tables["Product"].Keys)
{
if ((keyRelation.Type == KeyTypeEnum.adKeyForeign) && (keyRelation.RelatedTable == "ProductGroep"))
{
m_catDatabase.Tables["Product"].Keys.Delete(keyRelation.Name);
break;
}
}

Column clmnProdGroepID = m_catDatabase.Tables["ProductGroep"].Columns["ProductGroep_ID"];
clmnProdGroepID.Properties["Autoincrement"].Value = false;

The last line of code throws the exception.

.: I love it when a plan comes together :.
http://www.zonderpunt.nl