ADOX 多步 OLE DB 操作生成错误

发布于 2024-09-11 15:45:28 字数 1513 浏览 6 评论 0原文

我必须编写一个程序来关闭所有 Unicode 压缩和访问数据库 (.mdb) 中的所有“允许零长度”。

关闭“允许零长度”的方法非常有效。但是,关闭 Unicode 压缩的方法根本不起作用,并返回以下异常:

多步 OLE DB 操作生成错误。检查每个 OLE DB 状态值(如果有)。没有完成任何工作。

关于如何解决这个问题有任何线索吗?

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-09-18 15:45:28

您应该检查字符串中是否有没有适当 UNICODE 值的字符,这些字符通常是在从 MS Word 等应用程序复制和粘贴文本时引入的。特别是“智能报价”经常会引起问题。

另请查看以下线程(尽管它是用 C++ 编写的) C++ 中 ADOX 属性使用的讨论

您能够循环遍历属性并显示它们的当前值吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文