使用FirebirdSql.Data.FirebirdClient连接Firebird3无错误消息问题求助
FirebirdClient执行错误SQL时无法加载错误信息的问题
使用Firebird 3数据库服务器,通过.NET库FirebirdSql.Data.FirebirdClient(已尝试7.10.1及最新10.3.2版本)连接时,执行错误SQL语句(例如删除约束的语句)会触发如下错误:
FirebirdSql.Data.FirebirdClient.FbException: unsuccessful metadata update
ALTER TABLE mytable failed
No message for error code 336068738 found.
已尝试以下操作但问题仍未解决,还出现过错误码336068731:
- 将
firebird.msg文件复制到system32和wow64文件夹 - 配置环境变量
FIREBIRD_MSG=C:\Program Files\Firebird\Firebird_3_0\firebird.msg
相关C#代码如下:
if (DbProviderFactories.GetFactory("FirebirdSql.Data.FirebirdClient") is not FirebirdClientFactory fac) { throw new InvalidOperationException("FirebirdSql.Data.FirebirdClient.dll could not be loaded."); } var host = "localhost"; var user = "SYSDBA"; var pass = "masterkey"; var db = $"c:/databases/DelphiIn2025QuestionmarkQuestionmark.fdb"; var bld = new FbConnectionStringBuilder { Charset = "NONE", DataSource = host, Database = db, UserID = user, Password = pass, WireCrypt = FbWireCrypt.Enabled }; using (var con = fac.CreateConnection() as FbConnection) { if (con == null) { throw new InvalidOperationException("No FbConnection returned..."); } con.ConnectionString = bld.ConnectionString; con.Open(); using (var cmd = fac.CreateCommand() as FbCommand) { if (cmd == null) { throw new InvalidOperationException("No FbCommand returned..."); } cmd.Connection = con; cmd.CommandText = "alter table mytable drop constraint PK_uid"; cmd.ExecuteNonQuery(); } }
内容的提问来源于stack exchange,提问作者MHolzmayr
相关产品推荐
相关产品推荐

