tags:

views:

67

answers:

0

Hi,

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");

        }


    }