Search code examples
c#ms-accessadox

ADOX Multiple-step OLE DB operation generated errors


I have to make a program that turns off all Unicode compression and all "allow zero length" in an access database (.mdb) .

The method for turning off Allow Zero Length works very well. However, the method for turning off Unicode compression does not work at all and returns the following exception:

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

Any clue on how to solve this ?

private void TurnOffUnicodeCompressionInField(ADOX.CatalogClass catalogClass, String tableName, String field)
{           
    ADOX.Column column = catalogClass.Tables[tableName].Columns[field];
    ADOX.Property prop = column.Properties["Jet OLEDB:Compressed UNICODE Strings"];
    prop.Value = true;
}

private void TurnOffAllowZeroLengthInAllFields(ADOX.CatalogClass catalogClass, String tableName)
{
    foreach (ADOX.Column column in catalogClass.Tables[tableName].Columns)
        column.Properties["Jet OLEDB:Allow Zero Length"].Value = false; 
}

private void MyButton_Click(object sender, EventArgs e)
{
    String filePath = "";
    OpenFileDialog ofd = new OpenFileDialog();
    DialogResult result = ofd.ShowDialog();

    if (result == DialogResult.OK)
    {
         filePath = ofd.FileName; 
         ADOX.CatalogClass catDatabase = new ADOX.CatalogClass();
         catDatabase.let_ActiveConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath);

        // SoftwareTable 
        TurnOffAllowZeroLengthInAllFields(catDatabase,"Software"); 
        TurnOffUnicodeCompressionInField(catDatabase, "Software", "Description");
        TurnOffUnicodeCompressionInField(catDatabase, "Software", "Name");
    }                      
}

Solution

  • You should check your strings for characters that do not have appropriate UNICODE values, these can often be introduced when text is copied and pasted from an application like MS Word. Specifically the "smart quotes" often cause issues.

    Also take a look at the following thread (although it is in C++) Discussion on ADOX Property Usage in C++.

    Are you able to loop through the properties and display their current values?