连接到 D2010 上嵌入的 Firebird

发布于 2024-08-16 05:10:37 字数 1031 浏览 11 评论 0原文

我从 http://sites.google.com/site/dbxfirebird/ 我已经能够编译“测试连接”项目并让它运行。我将它指向我的测试数据库,如下所示:

procedure TMainForm.Button1Click(Sender: TObject);
var C: TSQLConnection;
begin
  C := TSQLConnection.Create(Self);
  try
    C.DriverName := 'FirebirdConnection';
    C.Params.Add('User_Name=SYSDBA');
    C.Params.Add('Password=masterkey');
    C.Params.Add('Database=C:\fbtest\test.fdb');
    C.Open;
    if C.Connected then
      ShowMessage('Connection is active')
  finally
    C.Free;
  end;
end;

当我运行它时,它工作正常。但是当我将完全相同的代码放入不同的项目中时,它不起作用。我已将 fbclient.dll(Firebird 嵌入式驱动程序 DLL,重命名为 fbclient)、其所有依赖项和 dbxdrivers.ini 文件复制到与项目的 EXE 运行所在的同一文件夹中。我看不出任何原因这不应该工作,但是对 .Open 的调用失败并显示:

项目 Project1.exe 引发异常 类 TDBXError 带有消息“未知” 驱动程序:FirebirdConnection'。

同样,这是对 Open 的调用。对 DriverName 的分配工作得很好。以前有人见过这个问题吗?为什么完全相同的代码在测试项目中可以工作,但不同的代码却不能工作,有什么方法可以修复它吗?

I downloaded the Firebird DBX driver from http://sites.google.com/site/dbxfirebird/ and I've been able to compile the "Test Connection" project and get it to run. I pointed it to my test DB like so:

procedure TMainForm.Button1Click(Sender: TObject);
var C: TSQLConnection;
begin
  C := TSQLConnection.Create(Self);
  try
    C.DriverName := 'FirebirdConnection';
    C.Params.Add('User_Name=SYSDBA');
    C.Params.Add('Password=masterkey');
    C.Params.Add('Database=C:\fbtest\test.fdb');
    C.Open;
    if C.Connected then
      ShowMessage('Connection is active')
  finally
    C.Free;
  end;
end;

When I run it, it works fine. But when I put that exact same code in a different project, it doesn't work. I've copied the fbclient.dll (Firebird embedded driver DLL, renamed to fbclient), all of its dependencies, and the dbxdrivers.ini file to the same folder as the project's EXE is running in. I can't see any reason why this shouldn't work, but the call to .Open fails with:

Project Project1.exe raised exception
class TDBXError with message 'Unknown
driver: FirebirdConnection'.

Again, this is on the call to Open. The assignment to DriverName works just fine. Has anyone seen this problem before? Why does the exact same code work in the test project but not a different one, and is there any way I can fix it?

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

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

发布评论

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

评论(3

最偏执的依靠 2024-08-23 05:10:37

我发现了问题。用于设置数据库驱动程序的加载类必须在 DBXDynalink.pas 的初始化部分中注册。测试项目在其 uses 子句中包含了 DBXDynalink,而我的项目则没有。我把它放进去,现在它可以工作了。

I found the problem. A loading class to set up the database driver had to be registered in the initialization section of DBXDynalink.pas. The test project included DBXDynalink in its uses clause, where mine didn't. I put that in and now it works.

狼性发作 2024-08-23 05:10:37

当您没有将相应的 DBX 驱动程序单元添加到您的使用列表中时,通常会发生此错误。尝试将 DBXFirebird 添加到您的使用列表中。

This error generally occurs when you don't add the respective DBX driver unit to your uses list. Try adding DBXFirebird to your uses list.

丑丑阿 2024-08-23 05:10:37

只是改变
C.DriverName := 'FirebirdConnection';

C.DriverName := 'Firebird';

并且会起作用!

Just change
C.DriverName := 'FirebirdConnection';
to
C.DriverName := 'Firebird';

and will work!

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