0

我正在尝试使用 FirebirdSQL .net 提供程序(使用 FirebirdSql.Data.FirebirdClient)从 Firebird 数据库连接和读取数据。这是代码:

FbConnection viewdataConnection=new FbConnection();
viewdataConnection.ConnectionString = "database=localhost:c:\\firebirdTest\\testDB.fdb;user=sysdba;password=firebird";
viewdataConnection.Open();

尝试打开()连接时,出现错误:

An unhandled exception of type 'FirebirdSql.Data.FirebirdClient.FbException' occurred in FirebirdSql.Data.FirebirdClient.dll
Additional information: Error occurred during login, please check server firebird.log for details

这是异常详细信息:

FirebirdSql.Data.FirebirdClient.FbException was unhandled
  ErrorCode=335545106
  HResult=-2147467259
  Message=Error occurred during login, please check server firebird.log for details
  SQLSTATE=08006
  Source=FirebirdSql.Data.FirebirdClient
  StackTrace:
       at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect()
       at FirebirdSql.Data.FirebirdClient.FbConnectionPoolManager.Pool.CreateNewConnectionIfPossibleImpl(FbConnectionString connectionString)
       at FirebirdSql.Data.FirebirdClient.FbConnectionPoolManager.Pool.GetConnection(FbConnection owner)
       at FirebirdSql.Data.FirebirdClient.FbConnection.Open()
       at UsingFirebird.FormUsers.FormUsersLoad(Object sender, EventArgs e) in C:\Users\vikas\Downloads\UsingFirebird\UsingFirebird\UsingFirebird\FormUsers.cs:line 46
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  InnerException: 
       ErrorCode=335545106
       HResult=-2146233088
       IsWarning=false
       Message=Error occurred during login, please check server firebird.log for details
       SQLSTATE=08006
       Source=FirebirdSql.Data.FirebirdClient
       StackTrace:
            at FirebirdSql.Data.Client.Managed.GdsConnection.Identify(String database)
            at FirebirdSql.Data.FirebirdClient.ClientFactory.CreateManagedDatabase(FbConnectionString options)
            at FirebirdSql.Data.FirebirdClient.ClientFactory.CreateDatabase(FbConnectionString options)
            at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect()
       InnerException: 

请帮忙。

4

2 回答 2

1

如果您需要在应用程序模式下运行 Firebird 服务器,请以管理员身份运行。

这为我解决了这个问题。Firebird 服务器需要对安装文件夹中的某些文件具有写入权限。

于 2020-09-27T17:57:19.197 回答
0

我在上面的评论的帮助下解决了这个问题。已采取措施解决:

  1. 更新 WireCrypt = 在 Firebird.conf 文件中启用
  2. 将所有应用程序包的读写权限授予 Firebird 安装文件夹 ( C:\Program Files\Firebird\Firebird_3_0)
  3. 我在文件夹中有我的数据库C:\FirebirdDb,我删除了这个数据库并在默认位置(即 Firebird 安装文件夹)创建了一个新数据库。

这是我的代码:

using (var connection = new FbConnection("database=localhost:test.fdb;user=sysdba;password=masterkey;Charset=NONE;"))
{
    connection.Open();
    using (var transaction = connection.BeginTransaction())
    {
        using (var command = new FbCommand("select * from testTable", connection, transaction))
        {
            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    var values = new object[reader.FieldCount];
                    reader.GetValues(values);
                    Console.WriteLine(string.Join("|", values));
                }
            }
        }
    }
}
于 2019-07-09T09:22:20.410 回答