更确切地说,我正在使用FireBird2.1和,并且我在c#中工作。
在这种情况下,我试图从c#将模式更改应用到数据库中,以“更新”我的数据库。在此过程中,我从firebird获得以下异常:
FirebirdSql.Data.FirebirdClient.FbException:未成功的元数据更新对象索引正在使用中
我将此解释为一个一致的问题,即同时存在另一个进程访问数据库。我不知道这是认证的原因,但这似乎是最有可能的情况。我认为这可能与删除和添加约束有关,因为它们是不可添加的,因为约束是不正确的,但是我能够在本地系统上运行这些命令,而不是在客户端站点上运行。无论如何,我目前有许多使用隔离级别"Serializable“包装在一个事务中的命令,并同时提交它们。由于这是一个升级,思想是它可以阻止所有其他用户的需要。
示例:
// note connection is pre-defined as a FbConnection, connected to the Database in question
FbTransaction transaction = Connection.BeginTransaction( IsolationLevel.Serializable );
// quite a bit of stuff gets done here, this is a sample
// I can run all the commands in this section in the isql tool and commit them all at once
// without error. NOTE: I have not tried to run them all on the client enviroment, and likely can't
string commandString = "ALTER TABLE Product DROP CONSTRAINT ProductType;";
FbCommand command = new FbCommand(commandString, Connection, transaction);
command.ExecuteNonQuery();
commandString = "ALTER TABLE Product ADD CONSTRAINT ProductType " +
"FOREIGN KEY ( TypeID ) REFERENCES Type ( TypeID ) " +
"ON UPDATE CASCADE ON DELETE NO ACTION;";
command.CommandText = commandString;
command.ExecuteNonQuery();
// other commands include:
// creating a new table
// creating 3 triggers for the new table
// commit the transaction
// this particular line actually "seems" to throw the exception mentioned
transaction.Commit();我的想法是尝试使用指定事务的“手动”方式来获得对表的更多独占访问,但我似乎无法让它工作,因为我不知道什么将和不会一起工作。
示例:
// Try to use FbTransactionOptions instead
// this statement complains about invalid options block when executing
FbTransaction transaction = Connection.BeginTransaction(
FbTransactionOptions.Consistency |
FbTransactionOptions.Exclusive |
FbTransactionOptions.Wait |
FbTransactionOptions.Write |
FbTransactionOptions.LockWrite |
FbTransactionOptions.NoRecVersion
);无论如何,我的问题是,如何获得数据库的独占访问权限来执行这些更新?我几乎想把每个人都踢出去,然后做他们。帮助和建议太多了!
新信息:我能够将数据带到本地,现在错误显示为:
FirebirdSql.Data.FirebirdClient.FbException:违反表"TYPE“上的外键约束"INTEG_72”
这是很清楚的,所以我会修复这个,并在现场试用。
好像已经修好了。
因此,总而言之,我在客户端系统上有一个例外:
FirebirdSql.Data.FirebirdClient.FbException:未成功的元数据更新对象索引正在使用中
我将数据带到本地系统,得到了另一个例外:
FirebirdSql.Data.FirebirdClient.FbException:违反表"TYPE“上的外键约束"INTEG_72”
这确实违反了外键约束。我能够更正更新程序,包括对数据和客户端站点进行适当更新的更正。由于某些原因,我似乎在客户端站点上收到了一个不正确的信息异常。
注:我也接受了jachguate在这篇文章中的回答,因为他提供了我认为是正确的答案。
发布于 2011-02-16 01:45:51
https://stackoverflow.com/questions/5010218
复制相似问题