ADOX 多步 OLE DB 操作生成错误
我必须编写一个程序来关闭所有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该检查字符串中是否有没有适当 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?